Regexp.MatchString in Go

Posted by GoDoc
Public (Editable by Users)

MatchString reports whether the string s contains any match of the regular expression re.

Go
Edit
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"))
}