From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15779 invoked from network); 24 Apr 2004 04:14:33 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 24 Apr 2004 04:14:33 -0000 Received: (qmail 19214 invoked by alias); 24 Apr 2004 04:14:19 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7402 Received: (qmail 19192 invoked from network); 24 Apr 2004 04:14:19 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 24 Apr 2004 04:14:19 -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 4:14:19 -0000 Received: (qmail 4432 invoked from network); 24 Apr 2004 04:14:19 -0000 Received: from wbar3.sjo1-4-11-009-147.sjo1.dsl-verizon.net (HELO candle.brasslantern.com) (4.11.9.147) by a.mx.sunsite.dk with SMTP; 24 Apr 2004 04:14:17 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id i3O4EEg17672 for zsh-users@sunsite.dk; Fri, 23 Apr 2004 21:14:14 -0700 X-Authentication-Warning: candle.brasslantern.com: schaefer set sender to schaefer@closedmail.com using -f From: Bart Schaefer Message-Id: <1040424041414.ZM17671@candle.brasslantern.com> Date: Sat, 24 Apr 2004 04:14:14 +0000 In-Reply-To: <20040423211540.GA1821@DervishD> Comments: In reply to DervishD "Expanding when matching" (Apr 23, 11:15pm) References: <20040423211540.GA1821@DervishD> X-Mailer: Z-Mail (5.0.0 30July97) To: Zsh Users Subject: Re: Expanding when matching MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Flag: YES X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: ****** X-Spam-Status: Yes, hits=6.2 required=6.0 tests=BAYES_01,RCVD_IN_DYNABLOCK, RCVD_IN_NJABL,RCVD_IN_NJABL_DIALUP,RCVD_IN_SORBS autolearn=no version=2.63 X-Spam-Hits: 6.2 X-Spam-Report: * -1.5 BAYES_01 BODY: Bayesian spam probability is 1 to 10% * [score: 0.0166] * 3.5 RCVD_IN_NJABL_DIALUP RBL: NJABL: dialup sender did non-local SMTP * [4.11.9.147 listed in dnsbl.njabl.org] * 2.6 RCVD_IN_DYNABLOCK RBL: Sent directly from dynamic IP address * [4.11.9.147 listed in dnsbl.sorbs.net] * 0.1 RCVD_IN_NJABL RBL: Received via a relay in dnsbl.njabl.org * [4.11.9.147 listed in dnsbl.njabl.org] * 1.5 RCVD_IN_SORBS RBL: SORBS: sender is listed in SORBS * [4.11.9.147 listed in dnsbl.sorbs.net] On Apr 23, 11:15pm, DervishD wrote: } } $ 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? I know Wayne has already answered, but: The # and % tokens in ${var/pat/rep} are not analogous to regex ^ and $. Rather, they're analogous to ${var#pat} and ${var%pat}. Does that help? For the analogs of ^ and $, you need (#s) and (#e) [and extendedglob]. $ print ${testvar/(#s)This*var(#e)/Replaced} } 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, setopt extendedglob c=0; while read line; do print ${${line#<->(#e)}:-$[++c]}; done (Replacing <-> with your pattern.)