package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(http(s)?:\/\/.)?(www\.)?(?:[-a-zA-Z0-9@:%_\+~#=]{1,63}\.)+[a-z]{2,6}\b((?:[-a-zA-Z0-9@:%_\+~#?&//="]+\.)*[-a-zA-Z0-9@:%_\+~#?&//="]+)?`)
var str = `asfd http://gskinner.co.im asfd
asfd m.skinner.com asfd
asfd www.gskinner.com asfd
asfd http://www.gskinner.com asfd
asfd www.gskinner.com?a=1&b=2 asfd
asfd gskinner.com?a="1"%203&b=2 asfd
asfd http://gskinner.com/a/b?c=3 asfd
asfd https://gskinner.com/a/b?c=3 asfd
asfd fdg.f.fg.gskinn.er.com/a/b?c=3 asfd
asfd ffgfgfgfgdfd/dfdfd.df asfd
asfd https://web.whatsapp.com/%F0%9F%8C%90/en asfd
asfd sdfsd://asdfw.asgd asfd
wealth.in..mutual sdf of 10k
wealth.Mutual,dfdfg sdf of 10k
wealth.Mutu/#index al of 10k
wealth.#MutualFundsSIP of 10k
wealth.$MutualFundsSIP of 10k
`
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/