Macro lazy_regex::regex_replace_all
source · regex_replace_all!() { /* proc-macro */ }
Expand description
Replaces all non-overlapping matches in the second argument with the value returned by the closure given as third argument.
The closure is given one or more &str
, the first one for
the whole match and the following ones for the groups.
Any optional group with no value is replaced with ""
.
Example:
let text = "Foo fuu";
let text = regex_replace_all!(
r#"\bf(?P<suffix>\w+)"#i,
text,
|_, suffix| format!("F<{}>", suffix),
);
assert_eq!(text, "F<oo> F<uu>");