// 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)^NEM.[A-Z0-9]{3}.[A-Z0-9]{3,6}.[0-9]{3}.[0-9]{1,3}$").unwrap();
let string = "NEM.ESB.IPAB.400.001
NEM.ESB.IPAB.400.003
NEM.ESB.TST.400.1
NEM.BPM.TST.400.1
NEM.ESB.TSTTST.400.1
NEM.BPM.TSTTST.400.1
NEM.ESB.TST.400.001
NEM.BPM.TST.400.001
NEM.ESB.TSTTST.400.001
NEM.BPM.TSTTST.400.001
NEM.ESB.AAA.000.000
NEM.BPM.AAA.000.000
NEM.ESB.AAAAAA.000.000
NEM.BPM.AAAAAA.000.000
NEM.ESB.ZZZ.999.999
NEM.BPM.ZZZ.999.999
NEM.ESB.ZZZZZZ.999.999
NEM.BPM.ZZZZZZ.999.999
ANEM.ESB.TST.400.1
AEM.BPM.TST.400.1
AEM.ESB.TSTTST.400.1
AEM.BPM.TSTTST.400.1
AEM.ESB.TST.400.001
AEM.BPM.TST.400.001
AEM.ESB.TSTTST.400.001
AEM.BPM.TSTTST.400.001
AEM.ESB.AAA.000.000
AEM.BPM.AAA.000.000
AEM.ESB.AAAAAA.000.000
AEM.BPM.AAAAAA.000.000
AEM.ESB.ZZZ.999.999
AEM.BPM.ZZZ.999.999
AEM.ESB.ZZZZZZ.999.999
AEM.BPM.ZZZZZZ.999.999
";
// 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/