From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28044 invoked from network); 13 Apr 2004 15:30:28 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 13 Apr 2004 15:30:28 -0000 Received: (qmail 6661 invoked by alias); 13 Apr 2004 15:29:53 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7341 Received: (qmail 6640 invoked from network); 13 Apr 2004 15:29:52 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 13 Apr 2004 15:29:52 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [130.225.247.86] by sunsite.dk (MessageWall 1.0.8) with SMTP; 13 Apr 2004 15:29:52 -0000 Received: (qmail 2313 invoked from network); 13 Apr 2004 15:29:52 -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; 13 Apr 2004 15:29:50 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id i3DFTmU20697 for zsh-users@sunsite.dk; Tue, 13 Apr 2004 08:29:48 -0700 X-Authentication-Warning: candle.brasslantern.com: schaefer set sender to schaefer@closedmail.com using -f From: Bart Schaefer Message-Id: <040413082948.ZM20696@candle.brasslantern.com> Date: Tue, 13 Apr 2004 08:29:48 -0700 In-Reply-To: <20040413120053.GA4420@DervishD> Comments: In reply to DervishD "Subscripting without temporaries" (Apr 13, 2:00pm) References: <20040413120053.GA4420@DervishD> X-Mailer: Z-Mail Lite (5.0.0 30July97) To: Zsh Users Subject: Re: Subscripting without temporaries MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: **** X-Spam-Status: No, hits=4.7 required=6.0 tests=RCVD_IN_DYNABLOCK, RCVD_IN_NJABL,RCVD_IN_NJABL_DIALUP,RCVD_IN_SORBS autolearn=no version=2.63 X-Spam-Hits: 4.7 On Apr 13, 2:00pm, DervishD wrote: > > I have an array containing strings of this type, one per 'slot': > > "Some text [particular text] Another text" > > For each line I want to be able to separate the three parts: the > 'Some text', the '[Particular text]', and the 'Another text'. > Which is the zsh-cool-way of doing the same? Actually I think backreferences in pattern matching is a pretty cool bit already. However, as you can treat strings as arrays and index them by character, and also do slices with pairs of indices: txt="Some text [particular text] Another text" print -l $txt[1,$txt[(i)\[]-2] $txt[(r)\[,(R)\]] $txt[$txt[(I)\]]+2,-1]