Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Subscripting without temporaries

    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

> 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