using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?<!<color=green>|[a-zA-Z0-9])(int|void|float|bool)(?!<\/color>|[a-zA-Z0-9])";
string substitution = @"<color=green>$1</color>";
string input = @"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;
}";
RegexOptions options = RegexOptions.Multiline;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);
}
}
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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx