We don't bite newbies here... much | |
PerlMonks |
realizing AND in regex?by LanX (Saint) |
on Sep 13, 2012 at 09:59 UTC ( [id://993441]=perlquestion: print w/replies, xml ) | Need Help?? |
LanX has asked for the wisdom of the Perl Monks concerning the following question:
Hi I'm using the regex engine to identify delimited fields matching certain conditions. Thanks to Perl's internal trie optimization of OR-conditions¹ it's far faster than using LIKE in mysql especially with hundreds of patterns to check
But now I got the requirement to find fields which match multiple regex at the same time ... and AFAIK the regex grammar doesn't have an AND operator The best guess I have is using zero-look-ahead assertions:
Well, already rather complicated for just two patterns ... and I doubt that it's fast ... any better suggestions?
Cheers Rolf Ok the following is already much better since it avoids or-chaining all possible orders of patterns just by anchoring the look-ahead at field-start. Footnotes: ¹) >5.10 IIRC
Back to
Seekers of Perl Wisdom
|
|