package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?i)\b(t)(?:anks *(?=[.?!]\n|to|for|in|ever)|[han]{3}([ks]{2}|x)+|hx|anx)\b`)
var str = `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/)`
var substitution = "$1hanks"
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/