package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^([a-zA-z]{3})(\d{4})(?:\d{2})?(_00)([0-7])(.*)$`)
var str = `HTH0919_001-werelwkre;lkj
HTH0919_007_dgfsdfs
HTH0919_008
HTH0919_009
HtH0919_010
HTH0919_097
HTH0919_098
HTH0919_099
HTH0919_100
HTH0919_111
HTH0919_101
HTH0919_899
HTH123456_020
^([a-zA-z]{3})(\d{4})(?:\d{2})?(_00)([0-7])(.*)$
^([a-zA-z]{3})(\d{4})(?:\d{2})?(_0)(?!98|99)(08|09|[1-9][0-9])(.*)$
^([a-zA-z]{3})(\d{4})(?:\d{2})?_(098|099|[1-9][0-9][0-9])(.*)$`
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/