// 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)(?<=SL{1}\d_)[0-9_]*|(?<=DM{1}\d\_)[0-9_]*").unwrap();
let string = "DM1_65_78109
SL1_78_72947
Input is DM1_813_1881
Input is DM2_793_1808
Input is DM1_SL1_609_604980
output should be 813_1881
output 609_604980
output 793_1808";
// 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/