// 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)\b\d+(?:,\d+)*").unwrap();
let string = "this is number 88 and rest of the text
this is number 2,563 and rest of the text
after I export it into excel. Problem is that I'm using custom tool (not programming language ) that excepts text as an input, regex pattern and export the output. This is why I need single pattern that eliminate space and produce either 88 or 2563 or any other number. The commas are every 3 positions obviously, so it can also be 1,345,321 as well as just single number 5 between \"this is number .... and rest of the text\"";
// 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/