/(?=^.*abc)(?=^.*pqr)(?=^.*xyz)/ and print "$_:matched"
for qw[ abcpqrxyz xyzpqrabc pqrxyzabc abpqrxyz];;
abcpqrxyz:matched
xyzpqrabc:matched
pqrxyzabc: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.
| [reply] [d/l] |
I don’t want to write 3 if conditions
Why not? It's simpler, and likely to be more efficient than the look ahead solution.
But say you want to look for substrings foo, bar and oba. Should foobar be a valid match? It contains all three substrings, but not without overlap.
| [reply] [d/l] [select] |
if ($str =~ /((abc)|(pqr)|(xyz))/)
$1 would contain first pattern that matches. (update: added external () to make $1 work) | [reply] [d/l] |