Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Extending regexes
FWIW, ast's extended and augmented regexps as supported by ksh93's [[ =~
]] operator or more generally in globs after ~(E) (extended) ~(A)
(augmented) do have AND and NOT operator.
That's \& and \! in ERE and & and ! in ARE.
ere() ksh -c '[[ $1 =~ $2 ]]' ksh "$@"
are() ksh -c '[[ $1 =~ (?A)$2 ]]' ksh "$@"
And then you can do
ere x '^([[:lower:]]\&.)$'
ere y '^x\!$'
are x '^([[:lower:]]&.)$'
are y '^x!$'
Also note that AND(A,B) can be done with NOT(OR(NOT(A), NOT(B))) so even
ksh88 or bash can do AND in their globs (with extglob in bash) with
!(!(A)|!(B))
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author