// 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"(?<date>[A-Za-z]+\s+\d{1,2}\s+\d{4})\s+(?<hours>\d+(?:\.\d+)?)\s+hrs").unwrap();
let string = "Nov 23 2021 10 hrs
Nov 24 2021 8.5 hrs
Nov 27 2021 8.75 hrs
Dec 3 2021 10.25 hrs";
// 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/