// 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"(?ism)<a (.*?)href="(.+?)"(.*?)>(.*?)<\/a>").unwrap();
let string = "<a href="http://www.google.be">Google</a>
<a href="bestand.flv" test=\"blablabla\">bestand</a>
<a target="_blank" href="Titels_opdrachten.pdf"><strong>titels van opdrachten in OLAT</strong></a>
<a id="5quot;>test</a>
<a href="hallo.png">hallo</a>";
let substitution = "<a href="$2">$4</a>";
// 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/