From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2916 invoked from network); 13 Apr 2004 16:41:11 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 13 Apr 2004 16:41:11 -0000 Received: (qmail 23514 invoked by alias); 13 Apr 2004 16:40:48 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7342 Received: (qmail 23439 invoked from network); 13 Apr 2004 16:40:48 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 13 Apr 2004 16:40:48 -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 16:40:48 -0000 Received: (qmail 32211 invoked from network); 13 Apr 2004 16:40:47 -0000 Received: from main.gmane.org (80.91.224.249) by a.mx.sunsite.dk with SMTP; 13 Apr 2004 16:40:46 -0000 Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1BDQxq-0003pc-00 for ; Tue, 13 Apr 2004 18:40:46 +0200 Received: from hippo.asfast.com ([216.182.10.250]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 13 Apr 2004 18:40:45 +0200 Received: from ljz by hippo.asfast.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 13 Apr 2004 18:40:45 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-users@sunsite.dk From: Lloyd Zusman Subject: Re: Subscripting without temporaries Date: Tue, 13 Apr 2004 12:40:39 -0400 Message-ID: References: <20040413120053.GA4420@DervishD> <040413082948.ZM20696@candle.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: hippo.asfast.com User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.2 (gnu/linux) Cancel-Lock: sha1:du6w7sAe49EH3udYHU5qIXh8XNA= Sender: news 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=none autolearn=no version=2.63 X-Spam-Hits: 0.0 Bart Schaefer writes: > 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] This is cool. But what options are necessary in order to make this work? The commands above produce this output for me: Some text [particular text] Another text This is the same as what I get with this: print -l $txt Thanks. -- Lloyd Zusman ljz@asfast.com