package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^https?:\/\/[!-~]+?&query=(?=.*[^!-~]).+$`)
var str = `https://weixin.sogou.com/weixin?type=2&ie=utf-8&s_from=hotnews&query=나.
https://weixin.sogou.com/weixin?type=2&ie=utf-8&s_from=hotnews&query=Tôi
https://weixin.sogou.com/weixin?type=2&ie=utf-8&s_from=hotnews&query=测试
https://weixin.sogou.com/weixin?type=2&ie=utf-8&s_from=hotnews&query=test`
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/