package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(((?:[+\-\/*]6+|6+[+\-\/*]|([^6]|\b)6{1,2}(?3)|(?3)6{6,}(?3)|[0-57-9]6+|6+[0-57-9])(*SKIP)(*F))|6)`)
var str = `66
老铁666这类的, 6666
三到五个六66666
5666有其他数字不替换
6665
566665
666666
66
+66
666-
`
var substitution = "六"
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/