// 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"(<(?![\/]?a)(?![\/]?img)([^>]+)>)").unwrap();
let string = "<!-- The line could look like this -->
<td align=right valign=bottom nowrap><div>January 24, 2013 </div></td>
<!-- Or this -->
<div>Is this system supported? </div>
<div>Is this system supported?</div>
<div><a href=\"game.com\"></a><p>Test</p></div>
<!-- Even this -->
<span>This is a span tag </div>
<img src=\"example.com/example.jpg\">
<img src=\"smiley.gif\" alt=\"Smiley face\" height=\"42\" width=\"42\">
<img src=\"example.com/example.jpg\">
<a href=\"game.com\"></a>
<div id=\"example\"><img src=\"example.com/example.jpg\">Hello World<a href=\"game.com\"></a></div>";
let substitution = "";
// result will be a String with the substituted value
let result = regex.replace_all(string, substitution);
println!("{}", result);
}
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/