mirror of
https://github.com/golang/go
synced 2024-11-26 13:48:05 -07:00
regexp: add example for NumSubexp
Updates #21450
Change-Id: Idf276e97f816933cc0f752cdcd5e713b5c975833
GitHub-Last-Rev: 198e585f92
GitHub-Pull-Request: golang/go#33490
Reviewed-on: https://go-review.googlesource.com/c/go/+/189138
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
cb30430af8
commit
68a6536848
@ -181,6 +181,13 @@ func ExampleRegexp_MatchString() {
|
||||
// true
|
||||
}
|
||||
|
||||
func ExampleRegexp_NumSubexp() {
|
||||
re := regexp.MustCompile(`(.*)((a)b)(.*)a`)
|
||||
fmt.Println(re.NumSubexp())
|
||||
// Output:
|
||||
// 4
|
||||
}
|
||||
|
||||
func ExampleRegexp_ReplaceAll() {
|
||||
re := regexp.MustCompile(`a(x*)b`)
|
||||
fmt.Printf("%s\n", re.ReplaceAll([]byte("-ab-axxb-"), []byte("T")))
|
||||
|
Loading…
Reference in New Issue
Block a user