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:
parent
57239ebfaa
commit
33f34b7adc
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user