package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(?<=^|\s)(?:(\w*')?)(@(\S+))`)
var str = `1. take this -> @Mark
2. take this -> @mark_2
3. take this -> @中国
4. take this -> l'@antro
5. don't take this -> 中国@中国.zh
6. don't take this -> 中国@google.zh
7. don't take this -> info@google.com
8. don't take this -> 99@test.com
9. don't take this -> 99@user
10. don't take this -> %&@user
11. take this -> dell'@altro
12. take this -> l'@mike`
var substitution = "<a href="/user/$3">$2</a>"
fmt.Println(re.ReplaceAllString(str, substitution))
}
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/