Finding the intersection between two regexes

Abigail abigail at
Fri Apr 25 21:24:57 BST 2014

On Fri, Apr 25, 2014 at 12:37:17PM -0400, Mark Fowler wrote:
> On Thu, Apr 24, 2014 at 7:47 PM, David Cantrell <david at> 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.

Do a pre-check? Reject anything that contains a non-ASCII character flatout.

About the only case where it's ok to use /\d/ is if you can garantee the
string you are matching against contains no non-ASCII digits.


More information about the mailing list