// 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".*(\?)").unwrap();
let string = "/maple-lodge-luxury-bed-and-breakfast/hotel/wanaka-nz.html?asq=1rrVgHWD%2ftbMPIK6tfFoOBewg1Z5%2buLS%2bSEDbaA%2fbS1Cje5wmB0pR0%2bLKktHrg4HC2IQVGwjWisHJHwdUYn88XKp1eogKj%2fzaqwNenpp8R5J8sYcWQ4ELgyWRz8zKFhqCpAzJy%2bIPcIhZIlXClDyysYo7iqvOXmWbg%2fTJAqzGDB7np8MbTsvr9hmeUc%2bP9lIlRlyZyrcrq%2fMBp7AbaEJbA%3d%3d&hotel=99830&tick=637329177909";
// result will be a tuple containing the start and end indices for the first match in the string
let result = regex.captures(string);
let (start, end) = match result {
Some((s, e)) => (s, e),
None => {
// ...
}
};
println!("{}", &string[start, end]);
}
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/