From 7f5434c44c75f25172d5d6106ad179d2e813bdd1 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 7 May 2019 09:41:46 +0200 Subject: [PATCH] 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 --- src/regexp/regexp.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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: -- 2.48.1