regex_captures!() { /* proc-macro */ }
Expand description
Extract captured groups as a tuple of &str.
If there’s no match, the macro returns None
.
If an optional group has no value, the tuple
will contain ""
instead.
Example:
let (whole, name, version) = regex_captures!(
r#"(\w+)-([0-9.]+)"#, // a literal regex
"This is lazy_regex-2.0!", // any expression
).unwrap();
assert_eq!(whole, "lazy_regex-2.0");
assert_eq!(name, "lazy_regex");
assert_eq!(version, "2.0");