// 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)(([a-zA-Z-éÉèÈàÀùÙâÂêÊîÎôÔûÛïÏëËüÜçÇæœ'.]*\s)\d*(\s[a-zA-Z-éÉèÈàÀùÙâÂêÊîÎôÔûÛïÏëËüÜçÇæœ']*)*,)*\d*(\s[a-zA-Z-éÉèÈàÀùÙâÂêÊîÎôÔûÛïÏëËüÜçÇæœ']*)+,\s([\d]{5})\s[a-zA-Z-éÉèÈàÀùÙâÂêÊîÎôÔûÛïÏëËüÜçÇæœ']+").unwrap();
let string = "Apt. 120, 9 Quai de Caumartin, 21305 Tourcoing
8 étage, 229 Boulevard de Caumartin, 41224 Clichy
8116 Boulevard Pierre Charron, 51703 Bordeaux
9 Quai de Caumartin, 21305 Tourcoing
Apt. 901, 8431 Boulevard Vaneau, 85330 Mérignac
314 Passage de la Férronnerie, 76818 Villejuif
1 étage, 6645 Avenue des Grands Augustins, 47851 Lyon
Apt. 889, 301 Place Adolphe Mille, 04320 Issy-les-Moulineaux
Apt. 470, 147 Allée, Voie des Grands Augustins, 37097 Asnières-sur-Seine
Apt. 356, 1 Allée, Voie de l'Abbaye, 83865 Champigny-sur-Marne
";
// 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/