package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^[a-z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}$`)
var str = `abcd-1234yz
abcd1234yz
abcd1234yz
abcd1234yz
1ca4tc7f-22ab-4d55-91d2-58a821ceb4c4
1ca4tc7f-227b-4d55-91d2-58a821ceb4c42
1ca4tc7f2-227b-4d55-91d2-58a821ceb4c49`
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/