package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?mi)^(0|\+98)9[0-9]{9}$`)
var str = `09156987452
09908472853
09153610882365
09158645287
+9814756842
+980915874622
+989908472853
+981283547
9836587498
+986859554
+989158497858
+9812457868
02154091563214587
12409156032145
091596356478
+982654789652
023654d
5588
879 091586424569
+9878546
+9999999999999
+989153610883
0915603551555555555
`
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/