// 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)\b(t)(?:anks *(?=[.?!]\n|to|for|in|ever)|[han]{3}([ks]{2}|x)+|hx|anx)\b").unwrap();
let string = "Fix:
thx 28,227 results
thanx 12,147
Tanks 1,087 <-- may actually mean _tanks_.
tanks in advance
tanks everyone
tanks for the help
Tanks!
thansk 518
tanx 125
tahnks 97
Leave alone:
thank you
tank, tanks of acid,
task, tasks
Suppose there is a production line with 8 tanks: each filled with a different substance for parts to be dipped in. The parts will be dropped into tanks by a crane along side the tanks. (http://stackoverflow.com/questions/25062870/)";
let substitution = "$1hanks";
// 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/