package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^(\+55)?[\s]?\(?(\d{2})?\)?[\s-]?(9?\d{4}[\s-]?\d{4})$`)
var str = `+55(16)91555-3456
22 98671 1032
+55 7134764819
(23)99378-4366
+5598683 1021
+551199603-3412
55 98214 9064
(55)98330-7156
(82) 936147156
+552430431084
2140028922
40028922
21 40028922
(21) 4002-8922
+55 21 4002 8922
+55(21)4002-8922
+55986320291`
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/