// 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)(?<![0-9])([0-9]{1,2}?)([0-9]{3})(?![0-9]+?)").unwrap();
let string = "Lorem 100 ipsum dolor 1000 sit 200 amet, 2000 consectetur adipiscing elit, sed 20000 do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in 300 voluptate 3000 velit esse 30000 cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat 400 cupidatat 4000 non proident, 40000 sunt in culpa qui officia deserunt mollit anim id est laborum.";
// 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/