in reply to Multiple matching using m///
The first lookahead will match 'balls' anywhere in the string; the second will match 'rings' anywhere in the string. Note that it doesn't matter whether 'balls' or 'rings' appears first.$_ = 'I threw the balls through the rings and won a prize!'; print "Gotcha!\n" if /^(?=.*balls)(?=.*rings)/s;
If you want to match another substring, you can just add another lookahead assertion.
I recall that I picked this one up from Abigail.
|
|---|