// 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)U\d*_([A-Za-z0-9\_]+)(?:\s*\d\s*\d*\s*\d*\s*\d*\s*\d*\s*\d*\s*\d*\s*(\d*)\s*\d*\s*\d*\s*\d*\s*(\d*)\s*\d*\s*\d*\s*(\d*))").unwrap();
let string = "U2_BOMBEROS_MERIDA4 1 734 4 0 0 0 0 54524 1 1 1 55302 0 0 54524 0 1 1 0 0 OFF 12 412 43 0 OFF OFF 0 0 1 1 1 10 10 10 10 0 0 OFF 3 0 0 0 OFF 90 180 0 OFF 0 0 0 OFF OFF OFF 90 180 0 OFF 0 0 OFF OFF OFF OFF OFF OFF ON 0 0 0 0 OFF OFF OFF OFF OFF OFF OFF OFF OFF OFF OFF OFF OFF 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 OFF 0 OFF OFF
U2_SAN_JAVIER_DEL_VALLE5 1 734 4 0 0 0 0 53955 1 1 1 55303 0 0 53955 0 1 1 0 0 OFF 12 412 43 0 OFF OFF 0 0 1 1 1 10 10 10 10 0 0 OFF 3 0 0 0 OFF 90 180 0 OFF 0 0 0 OFF OFF OFF 90 180 0 OFF 0 0 OFF OFF OFF OFF OFF OFF ON 0 0 0 0 OFF OFF OFF OFF OFF OFF OFF OFF OFF OFF OFF OFF OFF 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 OFF 0 OFF OFF
";
// 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/