// 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)<img[^>]+src="http:\/\/www\.example\.org\/image_to_be_removed\.jpg"[^>]*\>"#).unwrap();
let string = "<h1>Test article with HTML5 tags</h1>
<nav><a href=\"/link1/\">Link 1</a></nav>
<p>This is an example article. The article may or may not include html5 tags, images and other things.</p>
<img src=\"http://www.example.org/image_to_be_removed.jpg\">
<p>More example text.</p>";
// 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/