// 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)(?i)^(?:NPO|PRO|PCR|REQ|8)+(\d{7,8})(?!(\d))").unwrap();
let string = "NPO1234567
NPO12345678
NPO123456
NPO123456789
npo1234567
npo12345678
npo123456
npo123456789
PRO1234567
PRO12345678
PRO123456
PRO123456789
pro1234567
pro12345678
pro123456
pro123456789
PCR1234567
PCR12345678
PCR123456
PCR123456789
pcr1234567
pcr12345678
pcr123456
pcr123456789
REQ1234567
REQ12345678
REQ123456
REQ123456789
req1234567
req12345678
req123456
req123456789
81234567
812345678
8123456
8123456789
";
// 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/