// 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"(?m)(?<!<color=green>|[a-zA-Z0-9])(int|void|float|bool)(?!<\/color>|[a-zA-Z0-9])").unwrap();
let string = "pulic int Example(float x, bool y, int z)
{
return y ? (int)x : z;
}
public <color=green>int</color> ExamepleAlreadyReplaced(<color=green>float</color> x, <color=green>bool</color> y, <color=green>int</color> z)
{
return y ? (<color=green>int</color>)x : z;
}
public void EdgeCaseKeyWordsInNames()
{
var someint = int.MinValue;;
var somefloat = float.MaxValue;
var somebool = false;
var somevoid = () => { };
var int2 = 0;
var intX = 0;
}";
let substitution = "<color=green>$1</color>";
// 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/