// 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)([^\/]+)\/?
").unwrap();
let string = "https://www.ducati.com/es/es/motocicletas/monster/monster-797
https://www.ducati.com/es/es/motocicletas/diavel/diavel-1260
https://www.ducati.com/es/es/motocicletas/hypermotard/hypermotard
https://www.ducati.com/es/es/motocicletas/hypermotard/hypermotard-950
https://www.ducati.com/es/es/motocicletas/monster/monster-1200
https://www.ducati.com/es/es/motocicletas/monster/monster-1200-25-anniversario
https://www.ducati.com/es/es/motocicletas/monster/monster-1200r
https://www.ducati.com/es/es/motocicletas/monster/monster-797
https://www.ducati.com/es/es/motocicletas/monster/monster-821
https://www.ducati.com/es/es/motocicletas/multistrada/multistrada-1260
https://www.ducati.com/es/es/motocicletas/multistrada/multistrada-1260-enduro
https://www.ducati.com/es/es/motocicletas/multistrada/multistrada-950
https://www.ducati.com/es/es/motocicletas/multistrada/multistrada-enduro
https://www.ducati.com/es/es/motocicletas/panigale/1299-panigale-r-final-edition
https://www.ducati.com/es/es/motocicletas/panigale/959-panigale
https://www.ducati.com/es/es/motocicletas/panigale/panigale-v4
https://www.ducati.com/es/es/motocicletas/panigale/panigale-v4-r
https://www.ducati.com/es/es/motocicletas/supersport/supersport
https://www.ducati.com/es/es/motocicletas/xdiavel/xdiavel
";
// 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/