package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(?<!<color=green>|[a-zA-Z0-9])(int|void|float|bool)(?!<\/color>|[a-zA-Z0-9])`)
var 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;
}`
var substitution = "<color=green>$1</color>"
fmt.Println(re.ReplaceAllString(str, 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 Golang, please visit: https://golang.org/pkg/regexp/