]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20190923 snapshot
authorChet Ramey <chet.ramey@case.edu>
Tue, 24 Sep 2019 15:44:31 +0000 (11:44 -0400)
committerChet Ramey <chet.ramey@case.edu>
Tue, 24 Sep 2019 15:44:31 +0000 (11:44 -0400)
doc/bash.1
doc/bashref.texi

index 304e43a946a6f0224da863082b73a5d05cc7a265..264d137a2648b881a31248da9dee729ca802cebb 100644 (file)
@@ -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
index 5b44b8cd10cb08ca6722d6b9ab004b1ef959aa01..231356e5c6e71fe8865959fe3935644a74b9a508 100644 (file)
@@ -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.