// 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)(\d{1,}[,]\d{3} (W|w)ords)").unwrap();
let string = "This is an extremely AU crossover fic that asks the question what might have happened if Petunia Dursley hadn't found a young Harry Potter sleeping on her doorstep on the morning of the 2nd of November 1981. After all, Dumbledore was a bit careless with him 109,446 Words
1,000 words
12,345 words";
// 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/