Finding the intersection between two regexes

Mark Fowler mark at twoshortplanks.com
Fri Apr 25 17:37:17 BST 2014


On Thu, Apr 24, 2014 at 7:47 PM, David Cantrell <david at cantrell.org.uk> wrote:
> Mark wrote:
>> Those /d are incorrect. You want [0-9] or to use the /a regexp flag on a
>> suitably modern perl.
>
> My regexes come directly from Google's libphonenumber. They are happy to
> accept patches provided you sign your life away in blood.

Let's not do that.

> I require no such
> blood sacrifice for my code, but do insist that the tests still pass on perl
> 5.8.8.

That makes sense.  So we sadly can't use /a.

Ideally we'd want to munge the \d into [0-9].  It's as easy as
s/\\d/[0-9]/g, but that's relying on google to never use some
constructs in their regular expression (i.e. they don't put \\d in
their own regular expression.)

What do you think about that?  Otherwise, we need to start pulling
regular expressions apart (but if you're doing this anyway, maybe this
could be put in there.

Mark.


More information about the london.pm mailing list