summary refs log tree commit diff
path: root/Doc
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-01-17 21:48:25 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-01-17 21:48:25 +0000
commit8890e6e19ffa0bede585527671987972137009c7 (patch)
tree624d1830c56f33b2f3f1a3560306bad6336a4d32 /Doc
parenta2c89eb701e5ec3ffca33f25673a9600a9735930 (diff)
downloadzsh-8890e6e19ffa0bede585527671987972137009c7.tar.gz
zsh-8890e6e19ffa0bede585527671987972137009c7.tar.xz
zsh-8890e6e19ffa0bede585527671987972137009c7.zip
27600: extend =~ syntax to set positional variables for matches
Diffstat (limited to 'Doc')
-rw-r--r--Doc/Zsh/cond.yo24
1 files changed, 20 insertions, 4 deletions
diff --git a/Doc/Zsh/cond.yo b/Doc/Zsh/cond.yo
index 9d8f145f8..4b7304407 100644
--- a/Doc/Zsh/cond.yo
+++ b/Doc/Zsh/cond.yo
@@ -117,13 +117,29 @@ the tt(zsh/pcre) module, else it is tested as a POSIX
 extended regular expression using the tt(zsh/regex) module.
 Upon successful match, some variables will be updated; no variables
 are changed if the matching fails.
+
+If the option tt(BASH_REMATCH) is not set the scalar parameter
+tt(MATCH) is set to the substring that matched the pattern and
+the integer parameters tt(MBEGIN) and tt(MEND) to the index of the start
+and end, respectively, of the match in var(string), such that if
+var(string) is contained in variable tt(var) the expression
+`${var[$MBEGIN,$MEND]}' is identical to `$MATCH'.  The setting
+of the option tt(KSH_ARRAYS) is respected.  Likewise, the array
+tt(match) is set to the substrings that matched parenthesised
+subexpressions and the arrays tt(mbegin) and tt(mend) to the indices of
+the start and end positions, respectively, of the substrings within
+var(string).  The arrays are not set if there were no parenthesised
+subexpresssions.  For example, if the string `tt(a short string)' is matched
+against the regular expression `tt(s(...)t)', then (assuming the option
+tt(KSH_ARRAYS) is not set) tt(MATCH), tt(MBEGIN)
+and tt(MEND) are `tt(short)', 3 and 7, respectively, while tt(match),
+tt(mbegin) and tt(mend) are single entry arrays containing
+the strings `tt(hor)', `tt(4)' and `tt(6), respectively.
+
 If the option tt(BASH_REMATCH) is set the array
 tt(BASH_REMATCH) is set to the substring that matched the pattern
 followed by the substrings that matched parenthesised
-subexpressions within the pattern; otherwise, the scalar parameter
-tt(MATCH) is set to the substring that matched the pattern and
-and the array tt(match) to the substrings that matched parenthesised
-subexpressions.
+subexpressions within the pattern.
 )
 item(var(string1) tt(<) var(string2))(
 true if var(string1) comes before var(string2)