package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^https?:\/\/(?!localhost)[\.\w\d]{2,}`)
var str = `teste
http://www.outro.com.br
http://localhost
https://net.sec.org?outra=query
https://api.outro.com/?q
http://www.unsecuredapi.com
http//www
https:/www.com.br
https://regex101.com/
https://bin.com.br
http://bin.com
://teste
wss://outro
htt://mais.um.com`
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/