-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
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! 🙂
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels