// 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,]+|,+\D|\D,+|\d+,\d{3,}|\d{3,}(?:,\d+)?|^,|,$").unwrap();
let string = "Of course, 22d,3 equals 22,3, or A equals (empty string), 12 equals 12, need to remove anything that's not a number and my separator for float is ,
This is a 12 test with 12,34 digits and 123.23 or 123,1 or 123,12 or123,123 and 1234,1 but not 1,234 .html
test-test
34,344
34,34
34,1
34.1
1
1,1
1,12
12
100000
This is a ,comma here and ,,,,,3where ,
,,
,
This is , a a test 10,2333";
// 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/