package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(ebay(\.[a-z]{2,3}){1,2}/(itm|link/\?nav=item))`)
var str = `SHOULD MATCH
ebay.com/itm
ebay.nl/itm
anything.ebay.co.uk/link/?nav=item
SHOULD NOT MATCH
Customer service: http://ocsnext.ebay.com/ocs/home?
Sign in: https://signin.ebay.com/ws/
Privacy policy: http://pages.ebay.com/help/policies/user-agreement.html?rt=nc`
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/