package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(?:(?:http|https):\/\/)?(?:www.|m.)?facebook.com\/(?!home.php)(?:(?:\w)*#!\/)?(?:pages\/)?(?:[?\w\-]*\/)?(?:profile.php\?id=(?=\d.*))?([\w\.-]+)`)
var str = `http://www.facebook.com/jquery2dotnet
http://www.facebook.com/some.user
https://www.facebook.com/#!/my_page_id
http://www.facebook.com/pages/test
http://www.facebook.com/pages/test/123
https://www.facebook.com/#!/page_with_1_number
http://www.facebook.com/bounce_page#!/pages/test-Url/12345
https://www.facebook.com/bounce_page#!/my_page_id?v=app_1123325
https://www.facebook.com/notes/hyperarts-web-design
http://www.facebook.com/test.username
https://www.fb.me/jquery2dotnet
http://www.facebook.com/
http://m.facebook.com/home.php
http://m.facebook.com/test.username
https://mbasic.facebook.com/home.php?_rdr`
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/