// 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"(?mi)(?<=\bGASTEC).*(?:NO\s|,\s)(?<id>\b[1-9][ABHLMT][ABLMT]{0,1}|[1-9][0-9]{1,2}\s?[^-Pm ][BDLPT]{0,2})(?:\s|,).*$").unwrap();
let string = "GASTEC TUBE, BENZENE 1-10 PPM, 121L, //MUST MATCH
121L TUBE, BENZENE 1-10 PPM, GASTEC, //MUST MATCH <<<<-----
GASTEC TUBE FOR H2S, 0.5-15 PPM, //NO MATCH
GASTEC TUBE FOR CO, 1-25 PPM,//NO MATCH
KITAGAWA 128SD//NO MATCH
GASTEC TUBE FOR ETHYL ALCOHOL NO 112L , 100-2000 PPM,//MUST MATCH
GASTEC TUBES NO 111 METHYL ALCOHOL QC NO: 80777 MEASURING RANGE: 0.02-4.5% SCALE RANGE: 0.02-1.5%//MUST MATCH
GASTEC TUBES NO 4H BENZENE QC NO: 90985 MEASURING RANGE: 0.2-66 PPM SCALE RANGE: 0.2-20PPM//MUST MATCH
MSA TUBES NO 111 METHYL ALCOHOL QC NO: 80777 MEASURING RANGE: 0.02-4.5 SCALE RANGE: 0.02-1.5 (2)//NO MATCH
GASTEC TUBES NO 121SP BENZENE QC NO: 90985 MEASURING RANGE: 0.2-66 PPM SCALE RANGE: 0.2-20PPM (1)//MUST MATCH
GASTEC TUBE FOR BENZENE (RANGE 0.1-10 PPM) , 5 TEST S EACH PACKET, //NO MATCH
DRAGER TUBES NO 121SP BENZENE QC NO: 90985 MEASURING RANGE: 0.2-66 PPM SCALE RANGE: 0.2-20PPM 1 //NO MATCH
TOXIC GAS DETECTION TUBES, GASTEC General Deck Stores, Man: IMPA //NO MATCH
";
// 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/