mirror of
https://github.com/golang/go
synced 2024-09-25 11:30:13 -06: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() {
|
func ExampleMatch() {
|
||||||
matched, err := regexp.Match(`foo.*`, []byte(`seafood`))
|
matched, err := regexp.Match(`foo.*`, []byte(`seafood`))
|
||||||
fmt.Println(matched, err)
|
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:
|
// Output:
|
||||||
// true <nil>
|
// true <nil>
|
||||||
|
// false <nil>
|
||||||
|
// false error parsing regexp: missing closing ): `a(b`
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleMatchString() {
|
func ExampleMatchString() {
|
||||||
|
Loading…
Reference in New Issue
Block a user