From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29483 invoked from network); 23 Apr 2004 22:05:55 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 23 Apr 2004 22:05:55 -0000 Received: (qmail 13804 invoked by alias); 23 Apr 2004 22:05:37 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7401 Received: (qmail 13788 invoked from network); 23 Apr 2004 22:05:36 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 23 Apr 2004 22:05:36 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [130.225.247.86] by sunsite.dk (MessageWall 1.0.8) with SMTP; 23 Apr 2004 22:5:36 -0000 Received: (qmail 21874 invoked from network); 23 Apr 2004 22:05:36 -0000 Received: from dsl3-63-249-88-2.cruzio.com (HELO binome.blorf.net) (63.249.88.2) by a.mx.sunsite.dk with SMTP; 23 Apr 2004 22:05:34 -0000 Received: by binome.blorf.net (Postfix, from userid 1000) id E0D3D29E; Fri, 23 Apr 2004 15:05:32 -0700 (PDT) Date: Fri, 23 Apr 2004 15:05:32 -0700 From: Wayne Davison To: Zsh Users Subject: Re: Expanding when matching Message-ID: <20040423220532.GH16188@blorf.net> References: <20040423211540.GA1821@DervishD> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040423211540.GA1821@DervishD> User-Agent: Mutt/1.5.5.1+cvs20040105i X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=-0.0 required=6.0 tests=BAYES_44 autolearn=no version=2.63 X-Spam-Hits: -0.0 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..