package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^([gG][iI][rR] ?0[aA][aA])$|^((([a-zA-Z][0-9][0-9]?)|(([a-zA-Z][a-hA-Hj-yJ-Y][0-9][0-9]?)|(([a-zA-Z][0-9][a-zA-Z])|([a-zA-Z][a-hA-Hj-yJ-Y][0-9]?[a-zA-Z])))) ?[0-9][a-zA-Z]{2})$`)
var str = `AAA 1QG
gir 0aa
GIR0AA
gIR 0AA
giR 0AA
ig6 1qg
ig61qg
IG6 1QG
n22 5bp
n225bp
N22 5BP
`
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/