// 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)^(?P<unit_type>SFE)(?P<unit_size>100|80|63|50|40|32|25)(?P<mounting_type>P|Z)(?P<decompression_feature>0)(?P<sep_1>-)(?P<unit_series>1X)(?P<sep_2>/)(?P<seal_material>M)(?P<additional_details>(.|[0-9])*)$").unwrap();
let string = "SFE50Z0-1X/M
SFE32P0-1X/M
SFE32Z0-1X/M
SFE25Z0-1X/M
SFE50P0-1X/M
SFE40P0-1X/M
SFE63P0-1X/M
SFE63Z0-1X/M
SFE80Z0-1X/M
SFE40Z0-1X/M
SFE25P0-1X/M
SFE100Z0-1X/M
SFE80P0-1X/M
SFE100P0-1X/M
";
// 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/