Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regexp: add examples for all methods on regex.Regexp #21450

Closed
shoenig opened this issue Aug 15, 2017 · 12 comments
Closed

regexp: add examples for all methods on regex.Regexp #21450

shoenig opened this issue Aug 15, 2017 · 12 comments

Comments

@shoenig
Copy link
Contributor

@shoenig shoenig commented Aug 15, 2017

Something I've been wanting to do for a while is provide complete example coverage for methods defined on regexp.Regex. There are 36 methods, 11 of which have examples. Unless this isn't desired, I'd like to finish the other 25.

@odeke-em
Copy link
Member

@odeke-em odeke-em commented Aug 15, 2017

All yours @shoenig, thank you!

@slrz
Copy link

@slrz slrz commented Aug 16, 2017

I'm not sure that's a good idea. The methods are all variations on the same scheme. I don't see how enumerating the possible combinations and generating examples for them adds significant value over what's already there.

Please don't expand the docs with content that basically amounts to filler material just to satisfy some notion of exhaustiveness. If it's part of the docs, it should be worth to read. Excessive repetition is a time waster for people learning the API of a package.

If you can pull it off to demonstrate a new aspect of the package with every added example, go wild though!

@dsnet dsnet added the Documentation label Sep 1, 2017
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Mar 30, 2018
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 20, 2018

Change https://golang.org/cl/120145 mentions this issue: regexp: add more examples for Regexp methods

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 15, 2018

Change https://golang.org/cl/142197 mentions this issue: regexp: add examples for regexp functions

@agnivade
Copy link
Contributor

@agnivade agnivade commented Nov 20, 2018

Thank you @cn007b for adding more examples. Here are some remaining ones for which I think examples would be good to have to keep it consistent with the other examples.

I think once these are done, we can close this bug. The remaining ones are just simple variants of other methods which already have examples.

@Windsooon
Copy link

@Windsooon Windsooon commented May 21, 2019

@agnivade I created a PR for it. I didn't add an example for Regexp.Longest(). I think that is the default behavior for the RE module and I can't find a function to unset it.

@agnivade
Copy link
Contributor

@agnivade agnivade commented May 21, 2019

It's not the default. https://tip.golang.org/pkg/regexp/#Compile is leftmost-first. https://tip.golang.org/pkg/regexp/#CompilePOSIX is the one which is leftmost-longest.

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 6, 2019

Change https://golang.org/cl/189137 mentions this issue: regexp: add example for ReplaceAll

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 6, 2019

Change https://golang.org/cl/189138 mentions this issue: regexp: add example for NumSubexp

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 6, 2019

Change https://golang.org/cl/189177 mentions this issue: regexp: add examples for FindSubmatchIndex, FindAllIndex and Longest

@psampaz
Copy link
Contributor

@psampaz psampaz commented Aug 6, 2019

@agnivade #33489 #33497 #33490 cover all 5 missing examples

gopherbot pushed a commit that referenced this issue Sep 5, 2019
Updates #21450

Change-Id: Ia31c20b52bae5daeb33d918234c2f0944a8aeb07
GitHub-Last-Rev: cc85544
GitHub-Pull-Request: #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>
gopherbot pushed a commit that referenced this issue Sep 10, 2019
Updates #21450

Change-Id: Idf276e97f816933cc0f752cdcd5e713b5c975833
GitHub-Last-Rev: 198e585
GitHub-Pull-Request: #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>
gopherbot pushed a commit that referenced this issue Sep 18, 2019
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>
gopherbot pushed a commit that referenced this issue Sep 28, 2019
updates #21450

Change-Id: Ibffe0dadc1e1523c55cd5f5b8a69bc1c399a255d
GitHub-Last-Rev: 507f555
GitHub-Pull-Request: #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>
@agnivade
Copy link
Contributor

@agnivade agnivade commented Sep 28, 2019

All of the examples that I outlined have been submitted. I will go ahead and close this now. Thank you everyone who contributed to the examples.

@agnivade agnivade closed this Sep 28, 2019
@golang golang locked and limited conversation to collaborators Sep 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
9 participants
You can’t perform that action at this time.