Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Subscripting without temporaries
- X-seq: zsh-users 7343
- From: DervishD <raul@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Subscripting without temporaries
- Date: Tue, 13 Apr 2004 19:14:43 +0200
- Cc: Zsh Users <zsh-users@xxxxxxxxxx>
- In-reply-to: <040413082948.ZM20696@xxxxxxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: Pleyades
- References: <20040413120053.GA4420@DervishD> <040413082948.ZM20696@xxxxxxxxxxxxxxxxxxxxxxx>
Hi Bart :)
* Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> dixit:
> > 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?
> However, as you can treat strings as arrays and index them by character,
> and also do slices with pairs of indices:
OK, but then I need a temporary... Before the backreference trick
I tried the same using more or less what you suggests below, but I
didn't get far because I cannot do $array[EXP][Whatever] (well,
namely I was trying ${array[10]}[1,8], but zsh told me 'no matches
found').
> txt="Some text [particular text] Another text"
> print -l $txt[1,$txt[(i)\[]-2] $txt[(r)\[,(R)\]] $txt[$txt[(I)\]]+2,-1]
How can I do the same without the temporary? I mean, without
assigning to 'txt' or whatever the name of the temporary the result
of $array[EXP]
Thanks for your help :)
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author