From: Wayne Davison <wayned@users.sourceforge.net>
To: Zsh Users <zsh-users@sunsite.dk>
Subject: Re: Expanding when matching
Date: Fri, 23 Apr 2004 15:05:32 -0700 [thread overview]
Message-ID: <20040423220532.GH16188@blorf.net> (raw)
In-Reply-To: <20040423211540.GA1821@DervishD>
On Fri, Apr 23, 2004 at 11:15:40PM +0200, DervishD wrote:
> $ 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.
> 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":
counter=0
for number in {1..100}; do
case $number in
*0) print "Hit a ten! $((counter++))" ;;
*) print $number ;;
esac
done
..wayne..
next prev parent reply other threads:[~2004-04-23 22:05 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 [this message]
2004-04-24 7:48 ` DervishD
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=20040423220532.GH16188@blorf.net \
--to=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).