package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`\b[a-z]+(?:_[A-Z]+)?(?:_\d+)?\b|\b(?:[a-z]+_)?(?:[A-Z]+_)?\d+\b|\b[A-Z]+\b`)
var str = `az
AZ
09
az_09
AZ_09
az_AZ
az__
_AZ_
__09
az__09
_AZ_09
az_AZ_`
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/