// 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]+)?").unwrap();
let string = "/Versionnr: 5.131 //should be 5.13
/Versionname: somename v5.13b1
/Versionnr: 2.0..4 //should be 2.0
/Versionname: another name 2 v2.0.exp.4
/Versionnr: 18.01 //should be 18.0
/Versionname: somename v18.0-ALPHA1
/Versionnr: 7.2.42221..3634639 //should be 7.2.4222
/Versionname: another name v7.2.4222-1.L.3634639
/Versionnr: 5.0.220170112 //should be 5.0.2
/Versionname: somename v5.0.2 build 20170112
/Versionnr: 4.4.0.201701124401 //should be 4.4.0
/Versionname: another name v4.4.0.20170112b4401";
// 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/