From: Josh Roppo Date: Sat, 15 Jul 2017 20:40:22 +0000 (-0700) Subject: regexp: example for MatchString function X-Git-Tag: go1.9rc1~46 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9ca9f31f0b4c3fbe78a214a979e5aad409c16a48;p=gostls13.git regexp: example for MatchString function Change-Id: I5ca5a6689f0679154c24820466f5cf0011d0aaa6 Reviewed-on: https://go-review.googlesource.com/48959 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- diff --git a/src/regexp/example_test.go b/src/regexp/example_test.go index 8661d6d389..2ac92d4382 100644 --- a/src/regexp/example_test.go +++ b/src/regexp/example_test.go @@ -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"))