// 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)^(http[s]?:\/\/)?([^:\/\s]+)(:([^\/]*))?(\/\w+\.)*([^#?\s]+)(\?([^#]*))?(\.mp4|\.mkv)$").unwrap();
let string = "http://media.ch9.ms/ch9/360b/74fd8811-951f-40aa-bc24-91d51b82360b/Search.mp4
https://media.ch9.ms/ch9/360b/74fd8811-951f-40aa-bc24-91d51b82360b/Search.mp4
www.media.ch9.ms/ch9/360b/74fd8811-951f-40aa-bc24-91d51b82360b/Search.mp4
www.media.ch9.ms/ch9/360b/74fd8811-951f-40aa-bc24-91d51b82360b/Search.html
www.media.ch9.ms/ch9/360b/74fd8811-951f-40aa-bc24-91d51b82360b/Search.mkv";
// 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/