package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?im)^(?:|(https?:\/\/)?(|www)[.]?)(?:t|telegram)\.(?:me|dog)/(joinchat/|\+)?([\w-]+)`)
var str = `https://www.t.me/joinchat/I5antRHvea8ohaU7_RsYYQ
https://www.telegram.me/joinchat/I5antRHvea8ohaU7_RsYYQ
http://t.me/joinchat/I5antRHvea8ohaU7_RsYYQ
http://telegram.me/joinchat/I5antRHvea8ohaU7_RsYYQ
www.t.me/joinchat/I5antRHvea8ohaU7_RsYYQ
www.telegram.me/joinchat/I5antRHvea8ohaU7_RsYYQ
t.me/joinchat/I5antRHvea8ohaU7_RsYYQ
telegram.me/joinchat/I5antRHvea8ohaU7_RsYYQ
t.me/I5antRHvea8ohaU7_RsYYQ
t.dog/I5antRHvea8ohaU7_RsYYQ
https://t.dog/I5antRHvea8ohaU7_RsYYQ
`
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/