]> Cypherpunks repositories - gostls13.git/commitdiff
regexp: clarify docs re Submatch result
authorDmitry Vyukov <dvyukov@google.com>
Tue, 7 May 2019 07:41:46 +0000 (09:41 +0200)
committerDmitry Vyukov <dvyukov@google.com>
Wed, 8 May 2019 17:03:20 +0000 (17:03 +0000)
Currently we say that a negative index means no match,
but we don't say how "no match" is expressed when 'Index'
is not present. Say how it is expressed.

Change-Id: I82b6c9038557ac49852ac03642afc0bc545bb4a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/175677
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/regexp/regexp.go

index 88122d42508476bed1ade0f4552b4f55ea0b4c71..54cbd3777b112a96e11369d6eb54ac1b6fa7756e 100644 (file)
 // If 'Index' is present, matches and submatches are identified by byte index
 // pairs within the input string: result[2*n:2*n+1] identifies the indexes of
 // the nth submatch. The pair for n==0 identifies the match of the entire
-// expression. If 'Index' is not present, the match is identified by the
-// text of the match/submatch. If an index is negative, it means that
-// subexpression did not match any string in the input.
+// expression. If 'Index' is not present, the match is identified by the text
+// of the match/submatch. If an index is negative or text is nil, it means that
+// subexpression did not match any string in the input. For 'String' versions
+// an empty string means either no match or an empty match.
 //
 // There is also a subset of the methods that can be applied to text read
 // from a RuneReader: