// 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)(?:A1/EXT \"\w*\" \d+ (\d+)\s+(\d+)(?:[\w\s\-]+)CLASS(?:\s+[\w-]+)\s+(\w+)(?:[\w\s\-]+)EXTERNAL ALARM)|([\w]+$|[\w]+\s[\w]+$|[\w]+\s[\w]+\s[\w]+$|[\w]+\s[\w]+\s[\w]+\s[\w]+$)"#).unwrap();
let string = "A1/EXT \"BSCMAT2_G12BIPA\" 392 190602 1837
RADIO X-CEIVER ADMINISTRATION
BTS EXTERNAL FAULT
MO RSITE CLASS
RXOCF-181 SNMAIPIRE 1
EXTERNAL ALARM
ALTA_TEMPERATURA_CF_GSM
MENOR CF_GSM
MAYOR CF_GSM
DESCARGA_DE_BATERIAS_CF_GSM
FALLA_DE_AC_EXTERNO
A1/EXT \"BSCMAT2_G12BIPA\" 580 190619 1320
RADIO X-CEIVER ADMINISTRATION
BTS EXTERNAL FAULT
MO RSITE CLASS
RXOCF-244 LEZAMA 1
EXTERNAL ALARM
ALTA TEMPERATURA CF_GSM
MENOR CF_GSM
MAYOR CF_GSM
DESCARGA DE BATERIAS CF_GSM
FALLA DE AC EXTERNO
TRANSFER ACTIVO
MOTOGENERADOR ENCENDIDO
FALLA DE MOTOGENERADOR
BAJO NIVEL DE COMBUSTIBLE
";
// 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/