Re: Matching at least $x words out of @words

Sven Neuhaus <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <[email protected]>
On Thu, May 05, 2005 at 03:24:22PM +0100, José Castro wrote:
> So suppose you want a regular expression to match at least one of
> three words:
> 
> /word1|word2|word3/
> 
> What solution would you use if you wanted at least _two_ of those
> three words?

> Isn't there a neater (and probably twisted, of course) way of saying
> /match at least $x of the words in @words/

This is fwp. I would use this perlish solution:

@a = $x =~ /word1|word2|word3/g;
$count = scalar @a;

-Sven
-- 
Bill Dickey is learning me his experience.
		-- Yogi Berra in his rookie season.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.