MatchString reports whether the string s contains any match of the regular expression re.
package main import ( "fmt" "regexp" ) func main() { re := regexp.MustCompile(`(gopher){2}`) fmt.Println(re.MatchString("gopher")) fmt.Println(re.MatchString("gophergopher")) fmt.Println(re.MatchString("gophergophergopher")) }