|Keep It Simple, Stupid|
Regular expression for two required wordsby fsn (Friar)
|on Nov 13, 2001 at 15:27 UTC||Need Help??|
fsn has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks. I am a humble seeker of your wisdom.
I need help writing a RegExp that matches when two words both are present in a string, but the order is unknown. Also, the words might or might not be next to eachother. The regexp should NOT match when only one word is present.
With nested if's it is trivial, but I would like to do it with a single regexp.
Example: If I have a file:
I wan't to match lines 1,2,6 and 7, but not 3 thorugh 5, using some match for foo and bar.
Edit Masem 2001-11-13 - Changed title from 'Regular expression and'