// 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"\b004010H2[127][02379](?:A[12])?\b").unwrap();
let string = "$str = \"this is the code 004010H222A1 the rest is irrelevant\";
$str = \"the random number is 004010H223A2 ** anything else is irrelevant\";
$str = \"the last lottery number 004010H220A1 ~~ the rest is irrelevant\";
$str = \"yet another random sentence 004010H279A1 the rest is irrelevant\";
$str = \"any sentence before what i want 004010H279A1 the rest is irrelevant\";
$str = \"last winning number 004010H217~~~\";
";
// 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/