Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: pattern matching question
- X-seq: zsh-users 10828
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: pattern matching question
- Date: Wed, 11 Oct 2006 14:29:06 +0100
- In-reply-to: <20061011131505.GA4262@xxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20061011130213.GA6307@xxxxxxxxxxxxxxxxxxxxx> <20061011131505.GA4262@xxxxxxxxxxxxxxx>
Frank Terbeck wrote:
> list=("... one giraffe ..." "... two cows ..." "... one monkey ..." "... thre
> e lemmings ...")
> slist=(${(M)list:#*one [a-z]*})
To get the exact effect arno wants, you need an additional substitution
to remove the extra stuff, which brings it back to his original
proposal. I'd probably just do the simple
slist=(${${${(M)list:#*one [a-z]*}##*one }%% *})
which now has two extra pattern matches.
I can't offhand think of a way of both matching the one and extracting
the following word in one go. In practice it's unlikely to make a
noticeable difference unless you're really doing this a great deal---and
if speed's that important it's probably time to switch to a more
optimized scripting language.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
Messages sorted by:
Reverse Date,
Date,
Thread,
Author