Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Extended glob patterns in ${...#..} RE: Un-patch: new pattern matching code



>
> } I am not sure, that there is easy
> } way in Zsh to extract matched subpattern currently)
>
> There is ${(MSI:n:)...#...}, where n is a number.

It looks, like this does not work with extended glob patterns (3.1.6 pure or
pws-1):

bor@itsrm2:~%> foo=ab12xy
bor@itsrm2:~%> print ${(SM)foo#[[:digit:]]}
1
bor@itsrm2:~%> print ${(SM)foo#([[:digit:]])#}

And some more considerations:

 there is subtle problem: searching for "...sub1 ...sub2..." may give different
results as searching for sub1 first and   then for sub2

 the exact order number of desired match is not always available.

So, the above example is not exact replacement for submatches reference.
Granted, Zsh lived without it for a long time - but, if we have this now, why
not use it?

/andrej




Messages sorted by: Reverse Date, Date, Thread, Author