Macro lazy_regex_proc_macros::bytes_regex_replace

source ยท
bytes_regex_replace!() { /* proc-macro */ }
Expand description

Replaces the leftmost match in the second argument using the replacer given as third argument.

When the replacer is a closure, it 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 b"".

Example:

println!("{:?}", "ck ck".as_bytes());
let text = b"Fuu fuuu";
let text = bytes_regex_replace!(
    "f(u*)"i,
    text,
    b"ck",
);
assert_eq!(text, "ck fuuu".as_bytes());