// include the latest version of the regex crate in your Cargo.toml
extern crate regex;
use regex::Regex;
fn main() {
let regex = Regex::new(r"(?m)LABEL\d+=\[value=\h").unwrap();
let string = "event=RequestLogging foo LABEL1=[value=xyz description=desc1 metadata=[]] LABEL2=[value=abc description=desc2 metadata=[]] LABEL5=[value=def description=desc3 metadata=[]] LABEL6=[value=ghi description= metadata=[]]
bar LABEL3 LABEL4 LABEL5=[value= description= metadata=[]] LABEL6
LABEL5=[value=123 description= metadata=[]]";
// result will be an iterator over tuples containing the start and end indices for each match in the string
let result = regex.captures_iter(string);
for mat in result {
println!("{:?}", mat);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Rust, please visit: https://docs.rs/regex/latest/regex/