Re: Matching at least $x words out of @words
Rick Delaney <[email protected]>
| Newsgroups | gmane.comp.lang.perl.fun |
|---|---|
| Message-ID | <[email protected]> |
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/ > > > > What solution would you use if you wanted at least _two_ of > > those three words? > > $alt = join '|', qw( word1 word2 word3 ); > / ($alt) .* ($alt) (?(?{ $1 eq $2 })(?!)) /x / ($alt) .* (?!\1) ($alt) /x; -- Rick Delaney [email protected]