// 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)^La.+?no\s*(?'num_externe'.+?)\s.*\s(?:^.*\n)*.*installation\s*:\s*(?'ins_numins'.+?)\s+.*:\s*(?'apt_localisation'.+?)\s+.*:\s*(?'apt_nom'.+?)\s+.*:\s*(?'apt_email'.*?)\s+Typologie:.*\s*Motif.+?:\s*(?'qsy_lib'.+?)\s*Demande:\s*(?'commentaire_externe'.+)").unwrap();
let string = "Demandes - Date: 03/06/2019 à 09:58
La demande no 117530 a été externalisée à NORD ENGIE-Cofély,
Site concerné:
- Numéro d'installation : 2870521005
- Nom du Site : APE ST YRIEIX
Chargé d'affaire: Aurelie GUILLON
Email:
Typologie: Forfait heures multiservices
Motif détaillé: Demande
Demande: Objet : fixer la boîte à pharmacie petit format au mur. Bonjour, Je sollicite une intervention pour fixer la boîte à pharmacie petit format au mur en zone d'accueil à côté de l'extincteur. Cordialement. Sylvain CLUZEAU.
";
// 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/