// 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)(COM-)(ALM\d{1,2}_)(BIT$|BIT\d{3,}$|BIT\D.*|(?!BIT)\D.*)").unwrap();
let string = "COM-ALM2_BIT_1
COM-ALM2_BIT
COM-ALM2_AZIrgendwas_1
COM-ALM3_NameBIT
COM-ALM3_BITName
COM-ALM3_Name
COM-ALM2_BIT1
COM-ALM2_BIT15
COM-ALM11_BIT7
COM-ALM11_BIT11
OM-ALM_BIT1
COM-ALM_Name
COM-ALM11_BIT113
COM-ALM11_BIT1134";
// 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/