package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?mi)((\b(?:[a-z]|[^\x00-\x7F]){1,}\b).*?)(\b\2\b)(.*)$`)
var str = `Green shirt green hat
Green shirt greenish hat
You are an artistically gifted musically gifted individual
Naïve question naïve answer`
var substitution = "\1and\4"
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/