aboutsummaryrefslogtreecommitdiff
path: root/src/regexp
diff options
context:
space:
mode:
authorPantelis Sampaziotis <psampaz@gmail.com>2019-09-10 19:00:16 +0000
committerIan Lance Taylor <iant@golang.org>2019-09-10 20:33:25 +0000
commit68a653684823b6d63286bef785ab3a2df09ec552 (patch)
treeea070656e04589772d74fe1d3fc75e67b8d10e20 /src/regexp
parentcb30430af84a220f67d4cedc47c273c31051d291 (diff)
downloadgo-68a653684823b6d63286bef785ab3a2df09ec552.tar.gz
go-68a653684823b6d63286bef785ab3a2df09ec552.zip
regexp: add example for NumSubexp
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>
Diffstat (limited to 'src/regexp')
-rw-r--r--src/regexp/example_test.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/regexp/example_test.go b/src/regexp/example_test.go
index 2d87580eca..57b18e3fd7 100644
--- a/src/regexp/example_test.go
+++ b/src/regexp/example_test.go
@@ -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")))