Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Question on array processing.
- X-seq: zsh-users 10784
- From: "Larry P. Schrof" <larry@xxxxxxxxxx>
- To: Dan Nelson <dnelson@xxxxxxxxxxxxxxx>
- Subject: Re: Question on array processing.
- Date: Wed, 4 Oct 2006 15:18:24 -0500
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <20061004200759.GG54791@xxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20061004200025.GA3092@xxxxxxxxxxxxxxxxx> <20061004200759.GG54791@xxxxxxxxxxxxxxxx>
Awesome - thanks!
Huge favor - could the zshparam man page please be updated to
reflect this? I didn't see anything about it in the subscript flags section.
Also, while I'm requesting updates to the man page, I wanted to point
out a couple of typos I found if anybody wants to correct them.
On the zshparams man page, under the subscript flags section, there is
an identical typo that appears twice:
On the first line of both the 'w' and 'f' subscript flags, the text reads:
"If the parameter subscripted is a scalar than this flag makes"
The 'than' should probably be 'then'. Sorry to be anal. ;)
- Larry
On Wed, Oct 04, 2006 at 03:07:59PM -0500, Dan Nelson wrote:
> In the last episode (Oct 04), Larry P. Schrof said:
> > There is a subscript flag, s:<string> , (used with the 'w' flag) that
> > allows you to index into a string as if it were an array, using
> > <string> as a separator for elements.
> >
> > Here's my question:
> >
> > I absolutely can NOT figure out how to get zsh to use a single colon
> > (':') as a separator. No matter how I try to quote the second colon,
> > zsh sees the second colon in the expression as the termination for
> > the separator string.
> >
> > I'm tring to do something like:
> >
> > > str="these:are:some:words"
> > > echo ${str[(ws:::)2]}
> > zsh: bad math expression: operand expected at `::)2'
> >
> > I've also tried :":":, :\::, and :':': - none of those work.
> >
> > Is this a small flaw / hole in zsh's functionality?
>
> You can use any character as a delimiter, not just a colon:
>
> $ str="these:are:some:words"
> $ echo ${str[(ws/:/)2]}
> are
>
> --
> Dan Nelson
> dnelson@xxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author