Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Extended glob patterns in ${...#..} RE: Un-patch: new pattern matching code
- X-seq: zsh-workers 7397
- From: "Andrej Borsenkow" <Andrej.Borsenkow@xxxxxxxxxxxxxx>
- To: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>, "Zsh hackers list" <zsh-workers@xxxxxxxxxxxxxx>
- Subject: Extended glob patterns in ${...#..} RE: Un-patch: new pattern matching code
- Date: Sun, 8 Aug 1999 14:04:29 +0400
- Importance: Normal
- In-reply-to: <990807174848.ZM19657@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
>
> } 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