* [PATCH] documentation update =~ regex MATCH
@ 2009-01-15 0:53 Phil Pennock
0 siblings, 0 replies; only message in thread
From: Phil Pennock @ 2009-01-15 0:53 UTC (permalink / raw)
To: zsh-workers
The patch below should update the docs to make it clearer that no
variables are touched if regex matches fail.
yodl is currently segfaulting for me, so I can't test a make from them.
It looks like simple text changes which Can't Possibly Go Wrong, though,
so unless someone shouts I'll commit this anyway in a day or so.
Index: Doc/Zsh/cond.yo
===================================================================
RCS file: /home/cvsroot/zsh/Doc/Zsh/cond.yo,v
retrieving revision 1.5
diff -a -u -p -r1.5 cond.yo
--- Doc/Zsh/cond.yo 13 May 2007 20:18:28 -0000 1.5
+++ Doc/Zsh/cond.yo 15 Jan 2009 00:48:30 -0000
@@ -115,6 +115,8 @@ var(regexp). If the option tt(RE_MATCH_
var(regexp) is tested as a PCRE regular expression using
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 set the array
tt(BASH_REMATCH) is set to the substring that matched the pattern
followed by the substrings that matched parenthesised
Index: Doc/Zsh/mod_pcre.yo
===================================================================
RCS file: /home/cvsroot/zsh/Doc/Zsh/mod_pcre.yo,v
retrieving revision 1.6
diff -a -u -p -r1.6 mod_pcre.yo
--- Doc/Zsh/mod_pcre.yo 1 May 2007 22:05:05 -0000 1.6
+++ Doc/Zsh/mod_pcre.yo 15 Jan 2009 00:45:31 -0000
@@ -26,13 +26,15 @@ item(tt(pcre_match) [ tt(-v) var(var) ]
Returns successfully if tt(string) matches the previously-compiled
PCRE.
-If the expression captures substrings within parentheses,
+Upon successful match,
+if the expression captures substrings within parentheses,
tt(pcre_match) will set the array var($match) to those
substrings, unless the tt(-a) option is given, in which
case it will set the array var(arr). Similarly, the variable
var(MATCH) will be set to the entire matched portion of the
string, unless the tt(-v) option is given, in which case the variable
var(var) will be set.
+No variables are altered if there is no successful match.
)
enditem()
Index: Doc/Zsh/mod_regex.yo
===================================================================
RCS file: /home/cvsroot/zsh/Doc/Zsh/mod_regex.yo,v
retrieving revision 1.1
diff -a -u -p -r1.1 mod_regex.yo
--- Doc/Zsh/mod_regex.yo 2 May 2007 11:13:15 -0000 1.1
+++ Doc/Zsh/mod_regex.yo 15 Jan 2009 00:44:33 -0000
@@ -8,9 +8,11 @@ startitem()
findex(regex-match)
item(var(expr) tt(-regex-match) var(regex))(
Matches a string against a POSIX extended regular expression.
-The matched portion of the string will normally be placed in the tt(MATCH)
+On successful match,
+matched portion of the string will normally be placed in the tt(MATCH)
variable. If there are any capturing parentheses within the regex, then
the tt(match) array variable will contain those.
+If the match is not successful, then the variables will not be altered.
For example,
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-01-15 0:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-15 0:53 [PATCH] documentation update =~ regex MATCH Phil Pennock
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).