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

Re: pattern matching question



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