// 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"(?:\/p\/|$)(?:[^\/]*)(?<=-)(.*)(?=\/)").unwrap();
let string = "https://www.ikea.com/de/de/p/hallbar-abfalltrennungsloesung-mit-auszug-hellgrau-s09308825/
https://www.ikea.com/de/de/p/symfonisk-regal-wifi-speaker-schwarz-50357554/?tduid=d8b332c221610a36288c647f8959959f&utm_medium=affiliate&utm_name=generic&utm_term=conversion&utm_content=deeplink&utm_source=SmartApfel
https://www.ikea.com/de/de/p/symfonisk-tischleuchte-mit-wifi-speaker-weiss-30435157/?tduid=d8b332c221610a36288c647f8959959f&utm_medium=affiliate&utm_name=generic&utm_term=conversion&utm_content=deeplink&utm_source=SmartApfel
https://www.ikea.com/de/de/p/tradfri-gateway-weiss-40337806/?tduid=d8b332c221610a36288c647f8959959f&utm_content=feed&utm_medium=affiliate&utm_name=generic&utm_source=SmartApfel&utm_term=conversion
https://www.ikea.com/de/de/p/fyrtur-verdunklungsrollo-kabellos-batteriebetrieben-grau-40408196/?tduid=d8b332c221610a36288c647f8959959f&utm_content=feed&utm_medium=affiliate&utm_name=generic&utm_source=SmartApfel&utm_term=conversion
https://www.ikea.com/de/de/p/kadrilj-rollo-kabellos-batteriebetrieben-grau-90408127/?tduid=d8b332c221610a36288c647f8959959f&utm_content=feed&utm_medium=affiliate&utm_name=generic&utm_source=SmartApfel&utm_term=conversion";
// 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/