1
0
mirror of https://github.com/golang/go synced 2024-11-12 09:20:22 -07:00

regexp: add matching and finding examples

This commit adds examples for Match, Find,
FindAllSubmatch, FindSubmatch and Match functions.
This commit is contained in:
Vladimir Kovpak 2018-11-20 00:10:55 +02:00
parent 57239ebfaa
commit 33f34b7adc

View File

@ -28,9 +28,15 @@ func Example() {
func ExampleMatch() {
matched, err := regexp.Match(`foo.*`, []byte(`seafood`))
fmt.Println(matched, err)
matched, err = regexp.Match(`bar.*`, []byte(`seafood`))
fmt.Println(matched, err)
matched, err = regexp.Match(`a(b`, []byte(`seafood`))
fmt.Println(matched, err)
// Output:
// true <nil>
// false <nil>
// false error parsing regexp: missing closing ): `a(b`
}
func ExampleMatchString() {