]> Cypherpunks.ru repositories - gostls13.git/commitdiff
regexp: add example for NumSubexp
authorPantelis Sampaziotis <psampaz@gmail.com>
Tue, 10 Sep 2019 19:00:16 +0000 (19:00 +0000)
committerIan Lance Taylor <iant@golang.org>
Tue, 10 Sep 2019 20:33:25 +0000 (20:33 +0000)
Updates #21450

Change-Id: Idf276e97f816933cc0f752cdcd5e713b5c975833
GitHub-Last-Rev: 198e585f92db6e7ac126b49cd751b333e9a44b93
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>
src/regexp/example_test.go

index 2d87580ecaedaad767962b2e0db902bd5aa85a7c..57b18e3fd74b68486687fbd20b9fdf2f6d23b595 100644 (file)
@@ -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")))