package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^(?!021|031)\d*`)
var str = `022 123-456-2322
021 123-456-2322
031 123-456-2377
041 123-456-2322
021 555-456-2322
031 555-456-2322
0341 555-456-2322
021 123-456-2377
0341 123-456-2377
0341 123-021-2377
0341 123-031-2377`
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/