Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: pattern matching question
- X-seq: zsh-users 10826
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: pattern matching question
- Date: Wed, 11 Oct 2006 15:15:05 +0200
- In-reply-to: <20061011130213.GA6307@xxxxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Operating-system: Linux 2.6.16.16 i686
- References: <20061011130213.GA6307@xxxxxxxxxxxxxxxxxxxxx>
arno. <arno.@xxxxxxxxxx>:
> I have an array, for example:
>
> local -a list
> list=("... one giraffe ..." "... two cows ..." "... one monkey ..." "... three lemmings ...")
>
> ("..." can represent anything)
>
> and I want to get parts of each item each time a specific pattern
> occurs. For example, I want to get the word after "one". I therefore
> want to finish with an array containing ("giraffe" "monkey")
[...]
> What would be the better way to do that ?
[snip]
list=("... one giraffe ..." "... two cows ..." "... one monkey ..." "... three lemmings ...")
slist=(${(M)list:#*one [a-z]*})
print old:
print -l $list
print "\nnew:"
print -l $slist
[snap]
Regards, Frank
Messages sorted by:
Reverse Date,
Date,
Thread,
Author