package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(\+?(?:(84|0))(\s?[\-\u2010\u2011\u2012\u2013\u2014\u2015]?\s?)[357-9]\d{6}(?:\d{2}(?:\d{1})?)?)`)
var str = `1234567
76543211234
123456789
12345778
1234567890
+8412345678
84123456789
8412345
84123456
+1234567
+84
0123456
+84356763987
5123456
31234567
712345678
9123456789
+84-5123456
+84 5123456
05123456
0-5123456
+84 - 5123456
843378262
84337671542
84575516147
`
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/