// 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)(^(?:\/(_next\/data\/[^\/]{1,}))?(?:\/(?<i18n_locale>(?!_next\/)(en|de)))(?<user_matcher_from_i18n_pattern>\/((?!api|_next\/static|_next\/image|favicon.ico|sitemap.xml|robots.txt).*))(\.json)?[\/#\?]?$)|(^(?<user_matcher_from_base_matcher>\/((?!api|_next\/static|_next\/image|favicon.ico|sitemap.xml|robots.txt).*))[\/#\?]?$)").unwrap();
let string = "/api/some-api-route
/de/some-page-for-de-locale
/some-page-for-default-locale
";
// 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/