// 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)(?!"Level\s\d+")(?<!")"?Level\s\d+"?"#).unwrap();
let string = "This is a test with various \"Level 2\" and Level 5 and stuff.
Not sure how to treat \"Level 2 or Level 5\" though.
Also capturing Level 12 would be nice I guess? (Not \"Level 12\" of course though)
";
// 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/