Commit 9ca9f31f authored by Josh Roppo's avatar Josh Roppo Committed by Brad Fitzpatrick

regexp: example for MatchString function

Change-Id: I5ca5a6689f0679154c24820466f5cf0011d0aaa6
Reviewed-on: https://go-review.googlesource.com/48959Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent f062955e
......@@ -109,6 +109,17 @@ func ExampleRegexp_FindAllStringSubmatchIndex() {
// []
}
func ExampleRegexp_MatchString() {
re := regexp.MustCompile("(gopher){2}")
fmt.Println(re.MatchString("gopher"))
fmt.Println(re.MatchString("gophergopher"))
fmt.Println(re.MatchString("gophergophergopher"))
// Output:
// false
// true
// true
}
func ExampleRegexp_ReplaceAllLiteralString() {
re := regexp.MustCompile("a(x*)b")
fmt.Println(re.ReplaceAllLiteralString("-ab-axxb-", "T"))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment