Skip to content

Commit

Permalink
regexp: example for MatchString function
Browse files Browse the repository at this point in the history
Change-Id: I5ca5a6689f0679154c24820466f5cf0011d0aaa6
Reviewed-on: https://go-review.googlesource.com/48959
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
  • Loading branch information
Ropes authored and bradfitz committed Jul 15, 2017
1 parent f062955 commit 9ca9f31
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/regexp/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit 9ca9f31

Please sign in to comment.