package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?:https?:\/\/)?(?:www\.)?facebook\.com\/(?:(?:\w)*#!\/)?(?:pages\/)?(?:[\w\-]*\/)*?(?:profile.php\?id=(?=\d.*))?([\w\-]*)?(?:[\w\-\.]*)?`)
var str = `https://facebook.com/vietphu.nguyen.7?rc=p&refid=52&__tn__=R
https://facebook.com/shunchina?rc=p&refid=52&__tn__=R
https://facebook.com/phuocnguyen.nguyen.16568?rc=p&refid=52&__tn__=R
https://facebook.com/profile.php?id=100004404017311&rc=p&refid=52&__tn__=R`
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/