summaryrefslogtreecommitdiff
path: root/src/regexp/example_test.go
Commit message (Collapse)AuthorAgeFilesLines
* regexp: add (*Regexp).SubexpIndexSylvain Zimmer2020-04-101-0/+13
| | | | | | | | | | | | | SubexpIndex returns the index of the first subexpression with the given name, or -1 if there is no subexpression with that name. Fixes #32420 Change-Id: Ie1f9d22d50fb84e18added80a9d9a9f6dca8ffc4 Reviewed-on: https://go-review.googlesource.com/c/go/+/187919 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
* regexp: add examples for FindSubmatchIndex and LongestPantelis Sampaziotis2019-09-281-0/+28
| | | | | | | | | | | | updates #21450 Change-Id: Ibffe0dadc1e1523c55cd5f5b8a69bc1c399a255d GitHub-Last-Rev: 507f55508121a525de4d210e7ada1396ccaaf367 GitHub-Pull-Request: golang/go#33497 Reviewed-on: https://go-review.googlesource.com/c/go/+/189177 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* regexp: add more examples for Regexp methodsLiz Rice2019-09-181-0/+17
| | | | | | | | | | | | | | | | | | | | | | Since I first started on this CL, most of the methods have had examples added by other folks, so this is now one new example, and additions to two existing examples for extra clarity. The issue has a comment about not necessarily having examples for all methods, but I recall finding this package pretty confusing when I first used it, and having concrete examples would have really helped me navigate all the different options. There are more String methods with examples now, but I think seeing how the byte-slice methods work could also be helpful to explain the differences. Updates #21450 Change-Id: I27b4eeb634fb8ab59f791c0961cce79a67889826 Reviewed-on: https://go-review.googlesource.com/c/go/+/120145 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org>
* regexp: add example for NumSubexpPantelis Sampaziotis2019-09-101-0/+7
| | | | | | | | | | | | 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>
* regexp: add example for ReplaceAllpsampaz2019-09-051-0/+13
| | | | | | | | | | | | Updates #21450 Change-Id: Ia31c20b52bae5daeb33d918234c2f0944a8aeb07 GitHub-Last-Rev: cc8554477024277c3c1b4122344e9d14427680b3 GitHub-Pull-Request: golang/go#33489 Reviewed-on: https://go-review.googlesource.com/c/go/+/189137 Run-TryBot: Sylvain Zimmer <sylvinus@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* regexp: add ReplaceAllStringFunc exampleValentin Vidic2019-02-271-0/+8
| | | | | | | | | | Change-Id: I016312f3ecf3dfcbf0eaf24e31b6842d80abb029 GitHub-Last-Rev: 360047c9006dba643429c006f89d813d927999b3 GitHub-Pull-Request: golang/go#30445 Reviewed-on: https://go-review.googlesource.com/c/164257 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* regexp: use backquotes for all regular expression examplesVladimir Kovpak2018-11-201-21/+21
| | | | | | | | | | | | | This commit performs replace double quote to backquote, so now all examples looks consistent. Change-Id: I8cf760ce1bdeff9619a88e531161b9516385241b GitHub-Last-Rev: e3e636cebbf41528b8a73f9a3fe5afa10876f964 GitHub-Pull-Request: golang/go#28879 Reviewed-on: https://go-review.googlesource.com/c/150397 Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* regexp: add matching and finding examplesVladimir Kovpak2018-11-191-0/+54
| | | | | | | | | | | | | This commit adds examples for Match, Find, FindAllSubmatch, FindSubmatch and Match functions. Change-Id: I2bdf8c3cee6e89d618109397378c1fc91aaf1dfb GitHub-Last-Rev: 33f34b7adca2911a4fff9638c93e846fb0021465 GitHub-Pull-Request: golang/go#28837 Reviewed-on: https://go-review.googlesource.com/c/150020 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* regexp: examples for Regexp.FindIndex and Regexp.FindAllSubmatchIndex methodsAlex Myasoedov2018-06-301-0/+42
| | | | | | | | This commit adds examples that demonstrate usage in a practical way. Change-Id: I105baf610764c14a2c247cfc0b0c06f27888d377 Reviewed-on: https://go-review.googlesource.com/78635 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* regexp: add QuoteMeta exampleMatthew Broberg2018-06-121-0/+6
| | | | | | Change-Id: I0bbb53cad9a7c464ab1cfca381128f33496813ff Reviewed-on: https://go-review.googlesource.com/49130 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* regexp: examples for Regexp.Expand and Regexp.ExpandString functionsMatej Baćo2017-08-281-0/+64
| | | | | | | | | | | | | | Current documentation lacks simple examples for functions Regexp.Expand and Regexp.ExpandString whose usage is unclear from description alone. This commit adds examples that demonstrate usage in practical way. Fixes #21649 Change-Id: I7b2c06c8ab747f69a6578f0595bf0f3c742ac479 Reviewed-on: https://go-review.googlesource.com/59470 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* regexp: example for MatchString functionJosh Roppo2017-07-151-0/+11
| | | | | | | | Change-Id: I5ca5a6689f0679154c24820466f5cf0011d0aaa6 Reviewed-on: https://go-review.googlesource.com/48959 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* regexp: clarify example for 'FindString'Ivan Moscoso2017-07-151-3/+3
| | | | | | | | | | Clarifying that FindString only provides left-most match Change-Id: Ic6ecec12cca759fd4b3565ef5901a110843ffd56 Reviewed-on: https://go-review.googlesource.com/48609 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* regexp: add runnable example to regex.SplitSeth Hoenig2015-09-231-0/+22
| | | | | | | | | | | | The existing comment for regex.Split contains a plain text example, while many of the other regex functions have runnable examples. This change provides a runnable example for Split. Change-Id: I5373f57f532fe843d7d0adcf4b513061ec797047 Reviewed-on: https://go-review.googlesource.com/14737 Reviewed-by: Andrew Gerrand <adg@golang.org> Run-TryBot: Andrew Gerrand <adg@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* build: move package sources from src/pkg to srcRuss Cox2014-09-081-0/+148
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.