Macro lazy_regex_proc_macros::regex_if
source · regex_if!() { /* proc-macro */ }
Expand description
Return an Option
If the regex matches, executes the expression and return it as Some. Return None if the regex doesn’t match.
let grey = regex_if!(r#"^gr(a|e)y\((?<level>\d{1,2})\)$"#, "grey(22)", {
level.parse().unwrap()
});
assert_eq!(grey, Some(22));