Re: Matching at least $x words out of @words
Aaron Crane <[email protected]>
| Newsgroups | gmane.comp.lang.perl.fun |
|---|---|
| Message-ID | <[email protected]> |
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 =~ /\b\Q$_\E\b/ } @words;
--
Aaron Crane