// 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"(?i)(<a([^>]*)>)(<img([^>]*)>)").unwrap();
let string = "<a href=\"http://www.mobil.hr/wp-content/uploads/2017/12/Screenshot_20171219-102229.png\"><img class=\"aligncenter wp-image-4054\" src=\"http://www.mobil.hr/wp-content/uploads/2017/12/Screenshot_20171219-102229-563x1000.png\" alt=\"\" width=\"339\" height=\"602\" /></a>";
let substitution = "<div>\\1 \\3</div>";
// result will be a String with the substituted value
let result = regex.replace(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/