// 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"(?mi)(?<!test(?:\w|\s)*\W{0,14})test").unwrap();
let string = "Lorem ipsum Test sit amet, consectetur adipiscing elit. Vestibulum at erat ac enim malesuada pulvinar et nec ante. Cras erat ipsum, pellentesque vel volutpat ut, Test eu test. Test Quisque tincidunt varius mi. Suspendisse vitae lobortis diam. Vestibulum posuere massa id lectus faucibus posuere. Donec non sollicitudin est. Donec libero turpis, malesuada in Test";
// 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/