package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)\b(?!\w\s{1,2}\w+)\w(\w|\s){3}\d{10}`)
var str = ` a regular expression using C#/.Net that matches 1-4 alphanumerics followed by spaces, followed by 10 digits.
The catch is the number of spaces plus the number of alphanumerics must equal 4,
and the spaces must follow the alphanumerics, not be interspers
abcd1234567890 y
a 1234567890 y
ab 1234567890 y
1 1234567890 y
1 1234567890 n
1 1234567890 n
11234567890 n
a c 1234567890 n
a d1234567890 n
abcd 1234567890 n
`
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/