From: Chet Ramey Date: Tue, 24 Sep 2019 15:44:31 +0000 (-0400) Subject: commit bash-20190923 snapshot X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=31d704c98d5a9cd5a05ac016110c694442d80200;p=thirdparty%2Fbash.git commit bash-20190923 snapshot --- diff --git a/doc/bash.1 b/doc/bash.1 index 304e43a94..264d137a2 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -759,16 +759,25 @@ Bracket expressions in regular expressions must be treated carefully, since normal quoting characters lose their meanings between brackets. If the pattern is stored in a shell variable, quoting the variable expansion forces the entire pattern to be matched as a string. -Substrings matched by parenthesized subexpressions within the regular -expression are saved in the array variable +.if t .sp 0.5 +.if n .sp 1 +The pattern will match if it matches any part of the string. +Anchor the pattern using the \fB^\fP and \fB$\fP regular expression +operators to force it to match the entire string. +The array variable .SM -.BR BASH_REMATCH . +.B BASH_REMATCH +records which parts of the string matched the pattern. The element of .SM .B BASH_REMATCH -with index 0 is the portion of the string -matching the entire regular expression. -The element of +with index 0 contains the portion of +the string matching the entire regular expression. +Substrings matched by parenthesized subexpressions within the regular +expression are saved in the remaining +.SM +.B BASH_REMATCH +indices. The element of .SM .B BASH_REMATCH with index \fIn\fP is the portion of the diff --git a/doc/bashref.texi b/doc/bashref.texi index 5b44b8cd1..231356e5c 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi @@ -1049,10 +1049,16 @@ Bracket expressions in regular expressions must be treated carefully, since normal quoting characters lose their meanings between brackets. If the pattern is stored in a shell variable, quoting the variable expansion forces the entire pattern to be matched as a string. + +The pattern will match if it matches any part of the string. +Anchor the pattern using the @samp{^} and @samp{$} regular expression +operators to force it to match the entire string. +The array variable @code{BASH_REMATCH} records which parts of the string +matched the pattern. +The element of @code{BASH_REMATCH} with index 0 contains the portion of +the string matching the entire regular expression. Substrings matched by parenthesized subexpressions within the regular -expression are saved in the array variable @code{BASH_REMATCH}. -The element of @code{BASH_REMATCH} with index 0 is the portion of the string -matching the entire regular expression. +expression are saved in the remaining @code{BASH_REMATCH} indices. The element of @code{BASH_REMATCH} with index @var{n} is the portion of the string matching the @var{n}th parenthesized subexpression.