in reply to pattern matching words in any order

This achieves the AND requirement, but note the possibility of false matches if there is overlap between the two words (3rd example):

[0] Perl> $re = qr[(?=^.*this)(?=^.*that)];; [0] Perl> $_ =~ $re and print "$_ matched" for qw[thisthat thatthis thathis thisnthat thatnthis];; thisthat matched thatthis matched thathis matched ** thisnthat matched thatnthis matched

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP PCW It is as I've been saying!(Audio until 20090817)

Replies are listed 'Best First'.
Re^2: pattern matching words in any order
by grizzley (Chaplain) on Oct 26, 2009 at 08:53 UTC
    Actually /this/ && /that/ would return true in 3rd case, too, so OP should be happy with your (and ikegami's) solution.