// 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)^https:\/\/(?:www\.)?kuula.co\/share\/(?:[A-Za-z0-9]+\/)?(?:collection\/)?([A-Za-z0-9]+)(\?.*)?$").unwrap();
let string = "https://kuula.co
https://kuula.co/about
https://kuula.co/post
https://kuula.co/share
https://kuula.co/share/39u4$
https://kuula.co/post/7qQZ7
https://kuula.co/post/7qQZ7/collection/7lPZ8
http://kuula.co/share/7qQZ7
https://kuula.co/share/7qQZ7
https://kuula.co/share/collection/7lPZ8
https://kuula.co/share/7qQZ7?fs=1&abc=10
https://kuula.co/share/7qQZ7/collection/7lPZ8
https://kuula.co/share/collection/7lPZ8?vr=0
https://www.kuula.co/share/7qQZ7?abc=1
https://another-page.net/share/7qQZ7
https://kuula.co.another-page.com/share/7qQZ7";
// 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/