// 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)^([a-zA-z]{3})(\d{4})(?:\d{2})?(_00)([0-7])(.*)$").unwrap();
let string = "HTH0919_001-werelwkre;lkj
HTH0919_007_dgfsdfs
HTH0919_008
HTH0919_009
HtH0919_010
HTH0919_097
HTH0919_098
HTH0919_099
HTH0919_100
HTH0919_111
HTH0919_101
HTH0919_899
HTH123456_020
^([a-zA-z]{3})(\\d{4})(?:\\d{2})?(_00)([0-7])(.*)$
^([a-zA-z]{3})(\\d{4})(?:\\d{2})?(_0)(?!98|99)(08|09|[1-9][0-9])(.*)$
^([a-zA-z]{3})(\\d{4})(?:\\d{2})?_(098|099|[1-9][0-9][0-9])(.*)$";
// 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/