On Sun, 5 Nov 2006 19:11:06 +0100 Josh Hurst wrote:
> Can I concatenate shell pattern and ~(E) pattern in one [[ str == pat
> ]] expression?

there are a few issues for ~(E):

the affect on the underlying matcher -- ~(E) (extended) REs are not anchored,
whereas ksh REs are

~(E) puts the RE lexer into extended RE syntax, where (?K) is the syntax
to switch to ksh RE mode (borrowed from perl syntax)

the last mode of ~(E) or (?K) left to right determines the mode of the RE,
i.e., anchoring

this example should print 0 1 0 0 0 1 0 0

print $(
[[ bxz == @(a|b)?z ]]; print $?
[[ xbxzx == @(a|b)?z ]]; print $?
[[ bxz == ~(E)(a|b).z ]]; print $?
[[ xbxzx == ~(E)(a|b).z ]]; print $?
[[ bxz == ~(E)(a|b)(?K)?z ]]; print $?
[[ xbxzx == ~(E)(a|b)(?K)?z ]]; print $?
[[ bxz == @(a|b)~(E).z ]]; print $?
[[ xbxzx == @(a|b)~(E).z ]]; print $?
)

-- Glenn Fowler -- AT&T Research, Florham Park NJ --


Reply via email to