// 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#"(?ms)<meta[^>]*"(http[^"]+)"[^>]*>.*?(\1)"#).unwrap();
let string = "<meta property=\"og:url\" content=\"https://mywebsite.com/en/truth.html\"/>
text text
text
<img src=\"index_files/flag_lang_de.jpg\" width=\"28\" height=\"19\" title=\"de\" alt=\"de\" /></a> <a href=\"https://mywebsite.com/en/truth.html\"><img src=\"index_files/flag_lang_ru.jpg\" width=\"28\" height=\"19\" title=\"ru\" alt=\"ru\" /></a>
https://mywebsite.com/en/truth.html";
// 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/