package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`((S|T)([\d]{2})([A-Z]{2})([\d]{4})([A-Z])|(\d{9})([A-Z]))`)
var str = `Valid
000000000A
399999999Z
201902938G
T19SS0110H
T19SS0025B
200912345B
S09LL0001B
T09LS0001B
Invalid
S000000000
TZZZZZZZZZ
T0GBA12348
A123456672
S201562837
2009123456
T09LL00011
B09LL0001B`
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/