Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
RE: PATCH: new parameter expansion type?
- X-seq: zsh-workers 7579
- From: "Andrej Borsenkow" <Andrej.Borsenkow@xxxxxxxxxxxxxx>
- To: "Sven Wischnowsky" <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>, <zsh-workers@xxxxxxxxxxxxxx>
- Subject: RE: PATCH: new parameter expansion type?
- Date: Tue, 31 Aug 1999 17:18:21 +0400
- Importance: Normal
- In-reply-to: <199908301038.MAA20917@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
> >
> > Remember discussion of backreference in new regexp implementation?
> I think, we
> > should unify it with ${.../...} & Co code. There are two possibilities:
>
> Sure I remember that, but it's a different thing -- or how would you
> do an if-then-else with `${.../...}'? Or are you suggesting
> `${.../pat/repl-then/repl-else}'? Hm.
>
No. What I suggest is
1. enable use of subpatterns
2. save the results of last pattern match in defined variables, e.g. $MATCH
(scalar) for a whole match and $match (array) for subpatterns. Yes, it has som
eimpact, but e.g. in case of $foo == bar MATCH is reduntant (we match the whole
string anyway) and we can use option to turn it off.
3. now these variables can be used in ${.../...} and in ${...^...} in
replacement part. So, you can write
${foo^$~bar^$baz^$MATCH}.
Or
${foo/\([[:alpha:]]##\)\([[:letter:]]\)/$match[1]:$match[2]}
4. And these variables can be also used outside of expansion:
case $foo in
any_pattern)
print $match[3]
/andrej
Messages sorted by:
Reverse Date,
Date,
Thread,
Author