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
On Mon, May 09, 2005 at 10:27:48AM +0200, Sven Neuhaus wrote:
On Thu, May 05, 2005 at 03:24:22PM +0100, José Castro wrote:
This is fwp. I would use this perlish solution:
@a = $x =~ /word1|word2|word3/g;
$count = scalar @a;
Without commenting on the solution, the fwp version of this (and
* A. Pagaltzis [EMAIL PROTECTED] [2005-05-09 12:10]:
The problem with this and all the grep solutions is that you
^^
dont know whether you matched the same alternate multiple
times,
Err, that bit was non-sense, of course. I need some coffee.
On Thu, May 05, 2005 at 09:41:46PM -0400, Rick Delaney wrote:
On Fri, May 06, 2005 at 02:05:02AM +0200, A. Pagaltzis wrote:
* Jos? Castro [EMAIL PROTECTED] [2005-05-05 16:30]:
So suppose you want a regular expression to match at least one
of three words:
/word1|word2|word3/
Le jeudi 05 mai 2005 à 15:24, José Castro écrivait:
Hi, folks.
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?
my @words = qw( foo bar foobar );
On Fri, May 06, 2005 at 02:21:17AM -0700, Yitzchak Scott-Thoennes wrote:
On Thu, May 05, 2005 at 09:41:46PM -0400, Rick Delaney wrote:
/ ($alt) .* (?!\1) ($alt) /x;
Fails with words: (foo, foobar, foobaz) and string foofoobar.
So it does. The overlapping strings also cause
Rick Delaney writes:
The overlapping strings also cause problems for this method:
$x = grep { $string =~ m/$_/ } @words;
If $string is foobar and @words is qw(foo foobar) then this results
in two words found which I don't think the OP was looking for.
$x = grep { $string =~
-Original Message-
From: José Castro [mailto:[EMAIL PROTECTED]
Sent: 05 May 2005 15:24
[snip]
Isn't there a neater (and probably twisted, of course) way of saying
/match at least $x of the words in @words/
$x = grep { $string =~ m/$_/ } @words
http://www.bbc.co.uk/
This
safer:
$x = grep { $string =~ quotemeta } @words
Greg
-Original Message-
From: Iain Loasby [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 05, 2005 3:39 PM
To: José Castro; fwp@perl.org
Subject: RE: Matching at least $x words out of @words
-Original Message-
From: José
* Jos Castro [EMAIL PROTECTED] [2005-05-05 16:30]:
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?
$alt = join '|', qw( word1 word2 word3 );
/ ($alt)
10 matches
Mail list logo