From: Dmitry Vyukov Date: Tue, 7 May 2019 07:41:46 +0000 (+0200) Subject: regexp: clarify docs re Submatch result X-Git-Tag: go1.13beta1~378 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7f5434c44c75f25172d5d6106ad179d2e813bdd1;p=gostls13.git regexp: clarify docs re Submatch result 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 --- diff --git a/src/regexp/regexp.go b/src/regexp/regexp.go index 88122d4250..54cbd3777b 100644 --- a/src/regexp/regexp.go +++ b/src/regexp/regexp.go @@ -46,9 +46,10 @@ // 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: