|Problems? Is your data what you think it is?|
realizing AND in regex?by LanX (Chancellor)
|on Sep 13, 2012 at 09:59 UTC||Need Help??|
LanX has asked for the
wisdom of the Perl Monks concerning the following question:
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?
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.
¹) >5.10 IIRC