package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^(\w+) =.*\n(?=((?!\b\1\b)[^!])*(^\1 =|\Z))`)
var str = `a = 10
a * 3
foo = 8
2 - 1
b = 18
c = 10
d = 8
d = 4
cd = 72
d / 6
d + 1
e = 1
e = 2
e + 1
FooBar1 = 0
Fuz__ = 8
Fuz__ / 1
f = 1
f + 1
f = 2
f + 1
g = 1
1 / 5 * 8 + 4`
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/