Named capture groups allow accessing a capture by a str.
using regex
From the regex docs
use regex::Regex;
let re = Regex::new(r"Homer (?<middle>.)\. Simpson").unwrap();
let hay = "Homer J. Simpson";
let Some(caps) = re.captures(hay) else { return };
assert_eq!("J", &caps["middle"]);
Notice the (?<middle>.) with syntax ?<middle> to declare that capture group name middle.
using ere
Using ere, this indexed capture group compiles
use ::ere::{compile_regex, Regex};
const MY_REGEX1: Regex<2> = compile_regex!(r"Homer (.)\. Simpson");
and this named capture group fails
use ::ere::{compile_regex, Regex};
const MY_REGEX1: Regex<2> = compile_regex!(r"Homer (?<middle>.)\. Simpson");
with
An atom was expected but was invalid due to being a special character: `)`
Feature Request
Can ere add support for named capture groups?
I'd love to use them in my project.
Cool project! 🙂
Named capture groups allow accessing a capture by a
str.using
regexFrom the
regexdocsNotice the
(?<middle>.)with syntax?<middle>to declare that capture group namemiddle.using
ereUsing
ere, this indexed capture group compilesand this named capture group fails
with
Feature Request
Can
ereadd support for named capture groups?I'd love to use them in my project.
Cool project! 🙂