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

Re: Question on array processing.



In the last episode (Oct 04), Dan Nelson said:
> In the last episode (Oct 04), Larry P. Schrof said:
> > 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

Forgot to include the documentation that mentions this:

       The following flags (except p) are followed by one or more
       arguments as shown.  Any character, or the matching pairs
       `(...)', `{...}', `[...]', or `<...>', may be used in place of a
       colon as delimiters, but note that when a flag takes more than
       one argument, a matched pair of delimiters must surround each
       argument.


-- 
	Dan Nelson
	dnelson@xxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author