From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13764 invoked from network); 24 Apr 2004 08:09:17 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 24 Apr 2004 08:09:17 -0000 Received: (qmail 26605 invoked by alias); 24 Apr 2004 08:09:02 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7403 Received: (qmail 26579 invoked from network); 24 Apr 2004 08:09:01 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 24 Apr 2004 08:09:01 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [130.225.247.86] by sunsite.dk (MessageWall 1.0.8) with SMTP; 24 Apr 2004 8:9:1 -0000 Received: (qmail 11101 invoked from network); 24 Apr 2004 08:09:01 -0000 Received: from madrid10.amenworld.com (62.193.203.32) by a.mx.sunsite.dk with SMTP; 24 Apr 2004 08:08:58 -0000 Received: from DervishD.pleyades.net (212.Red-80-35-44.pooles.rima-tde.net [80.35.44.212]) by madrid10.amenworld.com (8.10.2/8.10.2) with ESMTP id i3O88sd31762; Sat, 24 Apr 2004 10:08:54 +0200 Received: from raul@pleyades.net by DervishD.pleyades.net with local (Exim MTA 2.05) id <1BHHtv-0000UV-00>; Sat, 24 Apr 2004 09:48:39 +0200 Date: Sat, 24 Apr 2004 09:48:39 +0200 From: DervishD To: Wayne Davison Cc: Zsh Users Subject: Re: Expanding when matching Message-ID: <20040424074839.GA1881@DervishD> Mail-Followup-To: Wayne Davison , Zsh Users References: <20040423211540.GA1821@DervishD> <20040423220532.GH16188@blorf.net> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20040423220532.GH16188@blorf.net> User-Agent: Mutt/1.4.2.1i Organization: Pleyades X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=-0.9 required=6.0 tests=BAYES_10 autolearn=no version=2.63 X-Spam-Hits: -0.9 Hi Wayne :) * Wayne Davison 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/