// 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+)").unwrap();
let string = "sdfdsfsdffsd 16.50sd - 57676766.0sd
16.50sd - 57676766.0sd
16.50sd - 57676766.0sd
sdfsdffsdf 6sd - 5.989898989sd sdfsdsdf
sdfdsf 6.50sd - 76.50sd sdfsdfsd
sdfsf sd 12sd - 15sd sdfdsdffsdff
16.50sd - 57sd
16sd - 50sd
1.50sd - 5.0sd
1sd - 5766.34sd the sdfdsfdsf spesdfdsfed
1sd - 5766.34sd the ssdfsdf sdfsdf";
// 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/