mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-26 16:40:29 +01:00
23375: Phil Pennock: =~, zsh/regex etc. etc.
This commit is contained in:
parent
eb4c3d4bf2
commit
7f03c3d851
14 changed files with 392 additions and 51 deletions
|
|
@ -109,6 +109,20 @@ backward compatibility and should be considered obsolete.
|
|||
item(var(string) tt(!=) var(pattern))(
|
||||
true if var(string) does not match var(pattern).
|
||||
)
|
||||
item(var(string) tt(=~) var(regexp))(
|
||||
true if var(string) matches the regular expression
|
||||
var(regexp). If the option tt(RE_MATCH_PCRE) is set
|
||||
var(regexp) is tested as a PCRE regular expression using
|
||||
the tt(zsh/pcre) module, else it is tested as a POSIX
|
||||
regular expression using the tt(zsh/regex) module.
|
||||
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.
|
||||
)
|
||||
item(var(string1) tt(<) var(string2))(
|
||||
true if var(string1) comes before var(string2)
|
||||
based on ASCII value of their characters.
|
||||
|
|
|
|||
|
|
@ -22,14 +22,17 @@ Studies the previously-compiled PCRE which may result in faster
|
|||
matching.
|
||||
)
|
||||
findex(pcre_match)
|
||||
item(tt(pcre_match) [ tt(-a) var(arr) ] var(string))(
|
||||
item(tt(pcre_match) [ tt(-v) var(var) ] [ tt(-a) var(arr) ] var(string))(
|
||||
Returns successfully if tt(string) matches the previously-compiled
|
||||
PCRE.
|
||||
|
||||
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).
|
||||
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.
|
||||
)
|
||||
enditem()
|
||||
|
||||
|
|
|
|||
|
|
@ -319,6 +319,13 @@ will cause case-insensitive matching. For example, tt(cvs+LPAR()/+RPAR())
|
|||
can match the directory tt(CVS) owing to the presence of the globbing flag
|
||||
(unless the option tt(BARE_GLOB_QUAL) is unset).
|
||||
)
|
||||
pindex(CASE_MATCH)
|
||||
cindex(case-insensitive regular expression matches, option)
|
||||
cindex(regular expressions, case-insensitive matching, option)
|
||||
item(tt(CASE_MATCH) <D>)(
|
||||
Make regular expressions using the tt(zsh/regex) module (including
|
||||
matches with tt(=~)) sensitive to case.
|
||||
)
|
||||
pindex(CSH_NULL_GLOB)
|
||||
cindex(csh, null globbing style)
|
||||
cindex(null globbing style, csh)
|
||||
|
|
@ -478,6 +485,15 @@ var(xx) is set to tt(LPAR())var(a b c)tt(RPAR()), are substituted with
|
|||
`var(fooabar foobbar foocbar)' instead of the default
|
||||
`var(fooa b cbar)'.
|
||||
)
|
||||
pindex(REMATCH_PCRE)
|
||||
cindex(regexp, PCRE)
|
||||
cindex(PCRE, regexp)
|
||||
item(tt(REMATCH_PCRE) <Z>)(
|
||||
If set, regular expression matching with the tt(=~) operator will use
|
||||
Perl-Compatible Regular Expressions from the PCRE library, if available.
|
||||
If not set, regular expressions will use the extended regexp syntax
|
||||
provided by the system libraries.
|
||||
)
|
||||
pindex(SH_GLOB)
|
||||
cindex(sh, globbing style)
|
||||
cindex(globbing style, sh)
|
||||
|
|
@ -1131,6 +1147,20 @@ enditem()
|
|||
|
||||
subsect(Shell Emulation)
|
||||
startitem()
|
||||
pindex(BASH_REMATCH)
|
||||
cindex(bash, BASH_REMATCH variable)
|
||||
cindex(regexp, bash BASH_REMATCH variable)
|
||||
item(tt(BASH_REMATCH))(
|
||||
When set, matches performed with the tt(=~) operator will set the
|
||||
tt(BASH_REMATCH) array variable, instead of the default tt(MATCH) and
|
||||
tt(match) variables. The first element of the tt(BASH_REMATCH) array
|
||||
will contain the entire matched text and subsequent elements will contain
|
||||
extracted substrings. This option makes more sense when tt(KSH_ARRAYS) is
|
||||
also set, so that the entire matched portion is stored at index 0 and the
|
||||
first substring is at index 1. Without this option, the tt(MATCH) variable
|
||||
contains the entire matched text and the tt(match) array variable contains
|
||||
substrings.
|
||||
)
|
||||
pindex(BSD_ECHO)
|
||||
cindex(echo, BSD compatible)
|
||||
item(tt(BSD_ECHO) <S>)(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue