From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27389 invoked from network); 23 Apr 2004 21:15:30 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 23 Apr 2004 21:15:30 -0000 Received: (qmail 3062 invoked by alias); 23 Apr 2004 21:15:09 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7400 Received: (qmail 3051 invoked from network); 23 Apr 2004 21:15:09 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 23 Apr 2004 21:15:09 -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 21:15:8 -0000 Received: (qmail 3346 invoked from network); 23 Apr 2004 21:15:08 -0000 Received: from madrid10.amenworld.com (62.193.203.32) by a.mx.sunsite.dk with SMTP; 23 Apr 2004 21:15:05 -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 i3NLF3W18628 for ; Fri, 23 Apr 2004 23:15:03 +0200 Received: from raul@pleyades.net by DervishD.pleyades.net with local (Exim MTA 2.05) id <1BH81M-0000TR-00>; Fri, 23 Apr 2004 23:15:40 +0200 Date: Fri, 23 Apr 2004 23:15:40 +0200 From: DervishD To: Zsh Users Subject: Expanding when matching Message-ID: <20040423211540.GA1821@DervishD> Mail-Followup-To: Zsh Users Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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.0 required=6.0 tests=BAYES_44 autolearn=no version=2.63 X-Spam-Hits: -0.0 Hi all :) I have a couple of doubts about Parameter Expansion, namely in the replacement field. The first doubt is just curiosity, of the kind that kills cats... The end of string anchor doesn't seems to work: $ testvar="This is my test var" $ print ${testvar/This*/Replaced} Replaced $ print ${testvar/#This*/Replaced} Replaced $ print ${testvar/var/Replaced} This is my test Replaced $ print ${testvar/var%/Replaced} This is my test var $ print ${testvar/#This*%/Replaced} This is my test var The example doesn't make much sense, but it illustrates what I mean. What I'm doing wrong? What am I not understanding? The second problem is more difficult, I'm afraid. This is best explained with an example: counter=0 ; for number in {1..100} do print ${number/*0*/Hit a ten! $((counter++))} done What I want is the substitution (and the postincrement) expanded and run only when the parameter matches, but instead it is (correctly) expanded on each call. This is just an example, I'm not trying to count 'tens', what I really need is a way of doing the expansion of the replacement expression only when it is a match. How can I achieve this with zsh? BTW, what I'm trying to do is to replace some numbers in one text that should be consecutive but are not, and they are interspersed with arbitrary text. What I know about them is that they are alone in a line, so they match certain regex, no problem about that. But between two of those numbers may be two, four, ten lines, I don't know :(( I know, I can do it with awk or sed, but I want to do it with zsh, just for the sake of it O:) Thanks a lot in advance and sorry for the noise. Hope some day I'm able to return all the help I get here :) Thanks, I mean it. Raúl Núñez de Arenas Coronado -- Linux Registered User 88736 http://www.pleyades.net & http://raul.pleyades.net/