fsn has asked for the wisdom of the Perl Monks concerning the following question:
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:
foo bar bar foo foo bar baz barbazfoo foofoobar
Any idea?
Edit Masem 2001-11-13 - Changed title from 'Regular expression and'
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Regular expression and
by davorg (Chancellor) on Nov 13, 2001 at 15:38 UTC | |
by crazyinsomniac (Prior) on Nov 13, 2001 at 16:20 UTC | |
by frankus (Priest) on Nov 13, 2001 at 15:50 UTC | |
Re: Regular expression and
by andye (Curate) on Nov 13, 2001 at 15:44 UTC | |
by jeroenes (Priest) on Nov 13, 2001 at 16:18 UTC | |
by fsn (Friar) on Nov 13, 2001 at 16:11 UTC |