// 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)(?i)(?:\w+\W+){0,9}?(?=.*(?:plot).*|.*(?:over).*)(?:\w+\W+){0,9}?(?=Charlie|Muir|Charlie Muir)\K(?:(?:Charlie|Muir|Charlie Muir)\s+)+").unwrap();
let string = "
cHarlie muir charlie charlie was over the moon the the the the the tge the the the
-the the the the the the the the the the the the the the the the the-
over was the the the moon parker parker charlie muir charlie
-the the the the the the the the the the the the the the the the the-
Charlie muir charlie was near the plot
-the the the the the the the the the the the the the the the the the-
ChArlie was far away from the plot was far away from the
-the the the the the the the the the the the the the the the the the-
the plot was far away from CharLie
-the the the the the the the the the the the the the the the the the-
the plot was far away from CharLie muir charlie
-the the the the the the the the the the the the the the the the the-
the over was far away from CHarlie muir
-the the the the the the the the the the the the the the the the the-
Mr cHARLIE was bowled over test was bowled after the ball
-the the the the the the the the the the the the the the the the the-
over the test was bowled muIR
-the the the the the the the the the the the the the the the the the-
the plot the ball the slot it will plot the test was bowled MuiR
-the the the the the the the the the the the the the the the the the-
";
// 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/