Commit ff785aa29f for golang
commit ff785aa29fc630bcf88531010c6c3d864d87893a
Author: nnnkkk7 <kurodanaoki0711pana@gmail.com>
Date: Mon Nov 30 06:42:43 2026 +0900
regexp: fix Submatch doc comments
FindStringSubmatch referred to its result as s, which is its argument.
AllSubmatch, AllStringSubmatch, FindAllSubmatch and FindAllStringSubmatch
were described as returning the locations of matches, but they return
the text.
Change-Id: Idc811f5d0588da1bb9dfa9b47f7e90aec1dda7e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/868281
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
diff --git a/src/regexp/regexp.go b/src/regexp/regexp.go
index 7b14bafa8a..0bddb0a7c7 100644
--- a/src/regexp/regexp.go
+++ b/src/regexp/regexp.go
@@ -880,7 +880,7 @@ func (re *Regexp) FindSubmatch(b []byte) [][]byte {
}
// FindStringSubmatch returns the first match for re in s, including submatches.
-// The overall match is s[0], the first submatch is s[1], and so on.
+// The overall match is m[0], the first submatch is m[1], and so on.
// The return value is nil for no match.
func (re *Regexp) FindStringSubmatch(s string) []string {
var dstCap [4]int
@@ -1046,16 +1046,14 @@ func (re *Regexp) AllStringIndex(s string) iter.Seq[[]int] {
return re.allStringIndex(s, -1)
}
-// AllSubmatch returns the locations of all matches for re in b,
-// including submatch locations.
+// AllSubmatch returns all the matches for re in b, including submatches.
// In each returned match m, the overall match is m[0],
// the first submatch is m[1], and so on.
func (re *Regexp) AllSubmatch(b []byte) iter.Seq[[][]byte] {
return re.allSubmatch(b, -1)
}
-// AllStringSubmatch returns the locations of all matches for re in s,
-// including submatch locations.
+// AllStringSubmatch returns all the matches for re in s, including submatches.
// In each returned match m, m[0] is the overall match,
// m[1] is the first submatch, and so on.
func (re *Regexp) AllStringSubmatch(s string) iter.Seq[[]string] {
@@ -1106,8 +1104,7 @@ func (re *Regexp) FindAllStringIndex(s string, n int) [][]int {
return collect(re.allStringIndex(s, n), n)
}
-// FindAllSubmatch returns the locations of all matches for re in b,
-// including submatch locations.
+// FindAllSubmatch returns all the matches for re in b, including submatches.
// In each returned match m, the overall match is m[0],
// the first submatch is m[1], and so on.
// If n >= 0, FindAllSubmatch returns no more than n matches.
@@ -1116,8 +1113,7 @@ func (re *Regexp) FindAllSubmatch(b []byte, n int) [][][]byte {
return collect(re.allSubmatch(b, n), n)
}
-// FindAllStringSubmatch returns the locations of all matches for re in s,
-// including submatch locations.
+// FindAllStringSubmatch returns all the matches for re in s, including submatches.
// In each returned match m, m[0] is the overall match,
// m[1] is the first submatch, and so on.
// If n >= 0, FindAllStringSubmatch returns no more than n matches.