package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(^\+[0-9]{2}|^\+[0-9]{2}\(0\)|^\(\+[0-9]{2}\)\(0\)|^00[0-9]{2}|^0)([0-9]{9}$|[0-9\-\s]{10}$)`)
var str = `Starts with either: +31, +31(0), (+31)(0), 0031, 0 followed by 10 digits, '-' or space
First part:
+311234567890
+31(0)1234567890
(+31)(0)1234567890
00311234567890
01234567890
Second part:
0031123456789-
003112345 789-
0031-23456780-
`
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/