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