// 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)^(?!.* (REV|LIB) .*).* COM .*$").unwrap();
let string = "0,5 MG COM CT BL AL/AL X 30
0,4 MG COM REV CT BL AL AL X 90
0,7 MG COM LIB PROL CT BL AL AL X 30
0,4 MG COM CT REV BL AL AL X 90
0,4 MG COMERCIAL CT REVENDEDOR BL AL AL X 90
0,4 MG REV COM CT BL AL AL X 90
0,7 MG LIB PROL COM CT BL AL AL X 30
";
// 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/