// 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#"(url *\( *(['"]*))(.*?)\2 *\)"#).unwrap();
let string = "url(wp-content/plugins/accordions/assets/global/webfonts/fa-brands-400.woff)
url(\"wp-content/plugins/accordions/assets/global/webfonts/fa-brands-400.woff\")
url('wp-content/plugins/accordions/assets/global/webfonts/fa-brands-400.woff')
url ( wp-content/plugins/accordions/assets/global/webfonts/fa-brands-400.woff )
url ( \"wp-content/plugins/accordions/assets/global/webfonts/fa-brands-400.woff\" )
url ( 'wp-content/plugins/accordions/assets/global/webfonts/fa-brands-400.woff' )
url(wp-content/plugins/accordions/assets/global/webfonts/fa-brands-400.woff)
url(\"wp-con)tent/plugins/accordions/assets/global/webfonts/fa-brands-400.woff\")
url('wp-cont)ent/plugins/accordions/assets/global/webfonts/fa-brands-400.woff')
url ( wp-content/plugins/accordions/assets/global/webfonts/fa-brands-400.woff )
url ( \"wp-con)tent/plugins/accordions/assets/global/webfonts/fa-brands-400.woff\" )
url ( 'wp-cont)ent/plugins/accordions/assets/global/webfonts/fa-brands-400.woff' )";
let substitution = "Subbed";
// 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/