From: DervishD <raul@pleyades.net>
To: Wayne Davison <wayned@users.sourceforge.net>
Cc: Zsh Users <zsh-users@sunsite.dk>
Subject: Re: Expanding when matching
Date: Sat, 24 Apr 2004 09:48:39 +0200 [thread overview]
Message-ID: <20040424074839.GA1881@DervishD> (raw)
In-Reply-To: <20040423220532.GH16188@blorf.net>
Hi Wayne :)
* Wayne Davison <wayned@users.sourceforge.net> 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/
next prev parent reply other threads:[~2004-04-24 8:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-23 21:15 DervishD
2004-04-23 22:05 ` Wayne Davison
2004-04-24 7:48 ` DervishD [this message]
2004-04-24 4:14 ` Bart Schaefer
2004-04-24 7:57 ` DervishD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040424074839.GA1881@DervishD \
--to=raul@pleyades.net \
--cc=wayned@users.sourceforge.net \
--cc=zsh-users@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).