package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(?x)
(?(DEFINE)(?<a>[a-zA-Z]))
\b(?=(?&a){2})
((?&a))
(?>
(?>((?&a))|\b)
(?=
(?&a)*+[^.]+
(
(?(3)\3|\b)
(?(4)\4|\2\b)
)
)
)++\b[^.]+\b\4`)
var str = `From Mars: come the 'sraM,a deadly species that hunts humans. It hunts from nighttime til sunrise (when it's lit) using radar to peek for our faint electrical output. Its head, shaped like a pot top, can emit a "hypersonic" pulse - in short time. Ironically, when faced vs humans, its pot top head is weak against decaf coffee which will keep it at bay. Oh, and beware on every third moon it gets no sleep.
We should also tttttttttttest tsett, aabcdefg another aa, and fina,lly this. None of these should match.`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
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/