const regex = new RegExp('(?<!<color=green>|[a-zA-Z0-9])(int|void|float|bool)(?!<\\/color>|[a-zA-Z0-9])', 'gm')
const str = `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;
}`;
const subst = `<color=green>$1</color>`;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log('Substitution result: ', 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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions