// 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)(?:\b\d+\b NR).*?(?=\b\d+\b NR|$)").unwrap();
let string = "1 NR 0PR 18OV DHO1O154 OCCHIALE ACETATO DONNA VISTA 1 NR 0PR 18OV NAG1O152 OCCHIALE ACETATO DONNA VISTA 1 NR 0PR 61QV 7AX1O156 OCCHIALE METALLO UOMO VISTA Descrizione Causale Vendita 2 NR 0AN4007 41 / 87 66 OCCHIALE NYLON UOMO SOLE Descrizione Causale Vendita 1 NR 0EA4001 50638G56 Valeria OCCHIALE NYLON UOMO SOLE Descrizione Causale Vendita - Pag 1 di 3 - Segue - 1 NR 0PO3042S 972 / M351 Sofia OCCHIALE ACETATO UOMO SOLE Descrizione Causale Vendita 1 NR 0AN3048 502 / 8G30 Valeria OCCHIALE METALLO UOMO SOLE Descrizione Causale Vendita 6 NR 0DG4204 27648764 OCCHIALE ACETATO UOMO SOLE Descrizione Causale Vendita 1 NR 0OX3123 31230453 Valeria OCCHIALE ACCIAIO UOMO VISTA";
// 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/