// 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).*mod_(\S+?)(-part-\d+)?\.(csv|json)").unwrap();
let string = "cid:d09004b7478a4f338bf647519edf71a3/tag:1595602064/aid:095438ff38da41e4444059fdbd9af9fd/pid:64756d6d792c484f555345424152415448454f4e2c31302e3136302e332e3232342c323032302d30372d32375432325f35385f31315a2e786d6ce3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855/mod_dirlist-part-000001.json.gz";
// 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/