Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Expanding when matching
- X-seq: zsh-users 7403
- From: DervishD <raul@xxxxxxxxxxxx>
- To: Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx>
- Subject: Re: Expanding when matching
- Date: Sat, 24 Apr 2004 09:48:39 +0200
- Cc: Zsh Users <zsh-users@xxxxxxxxxx>
- In-reply-to: <20040423220532.GH16188@xxxxxxxxx>
- Mail-followup-to: Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: Pleyades
- References: <20040423211540.GA1821@DervishD> <20040423220532.GH16188@xxxxxxxxx>
Hi Wayne :)
* Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx> dixit:
> > $ testvar="This is my test var"
> > $ print ${testvar/var%/Replaced}
> > This is my test var
> This should be:
> $ print ${testvar/%var/Replaced}
> This is my test Replaced
> The leading '%' indicates that the match must occur at the end.
I may have read the zsh info section 'Parameter Expansion'
hundreds of times, maybe more, and *always* I've read it, I've come
to the conclusion that the '#' and the '%' were the equivalent to '^'
and '$' in POSIX regexes, which they are not. The problem here is
that I did a bad reading of the manual, sorry :(( Since the symbols
used (# and %) are the same as in other parameter substitutions, that
should have worked as mnemonic O:)
Again, sorry for the noise, next time I promise to better read
the manual, if I can afford the brain...
> > What I want is the substitution (and the postincrement) expanded and
> > run only when the parameter matches
> If you don't need it done in a single line, you can always use "case":
The problem here is when the regex is not a simple number, but a
more complicated one which needs backrefs and the like when
substituting. Could it be done with 'case'?.
Thanks a lot for your help, Wayne.
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author