package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^\/(?!(admin\b)|login\b\/*|home\b\/*|sign_up\b\/*)[a-zA-Z0-9_\/]*`)
var str = `/
/admin
/login
/admin/xxx
/login/xxx
/home/xxx/login/xxx
/sign_up/xxx/login/xxx
/admintest/xxx
/loginetest/xxx
/hometset/xxx
/sign_uptest/xxx
/others
/others/xxx/login/xxx
/others/xxx/others/xxx/login/xxx`
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/