Re: Finding the intersection between two regexes

2014-04-25 Thread Hakim C
On 25 April 2014 06:38, Abigail abig...@abigail.be wrote: On Fri, Apr 25, 2014 at 12:47:04AM +0100, David Cantrell wrote: I'm with Mark. My view is that a /\d/ is almost always wrong, on any perl released in this century. /\d/a or /(?a:\d)/ is just a really ugly and confusing way to write

Re: Finding the intersection between two regexes

2014-04-25 Thread David Cantrell
On Fri, Apr 25, 2014 at 07:38:55AM +0200, Abigail wrote: On Fri, Apr 25, 2014 at 12:47:04AM +0100, David Cantrell wrote: On 24/04/2014 23:28, Mark Fowler wrote: On Thursday, April 24, 2014, Michael Lush mjl...@gmail.com wrote: if ($x =~ /^246[2-9]\d{6}$/ and $x =~

Re: Finding the intersection between two regexes

2014-04-25 Thread Mark Fowler
On Thu, Apr 24, 2014 at 7:47 PM, David Cantrell da...@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

Re: Finding the intersection between two regexes

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

Re: Finding the intersection between two regexes

2014-04-25 Thread David Cantrell
On Fri, Apr 25, 2014 at 12:37:17PM -0400, Mark Fowler wrote: David Cantrell wrote: 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. Although you can use fancy new features in the build scripts.

Re: Finding the intersection between two regexes

2014-04-24 Thread Michael Lush
On Tue, Apr 22, 2014 at 5:05 PM, Paul Makepeace pa...@paulm.com wrote: If your goal is to simply identify overlaps rather than generate encompassing regexes, you could try attacking it with intelligently/heuristically generated random numbers. Paul Its just about possible to brute force

Re: Finding the intersection between two regexes

2014-04-24 Thread Mark Fowler
On Thursday, April 24, 2014, Michael Lush mjl...@gmail.com wrote: if ($x =~ /^246[2-9]\d{6}$/ and $x =~ /^246(?:(?:2[346]|45|82)\d|25[0-4])\d{4}$/ ) Those /d are incorrect. You want [0-9] or to use the /a regexp flag on a suitably modern perl. Mark

Re: Finding the intersection between two regexes

2014-04-24 Thread David Cantrell
On 24/04/2014 23:28, Mark Fowler wrote: On Thursday, April 24, 2014, Michael Lush mjl...@gmail.com wrote: if ($x =~ /^246[2-9]\d{6}$/ and $x =~ /^246(?:(?:2[346]|45|82)\d|25[0-4])\d{4}$/ ) Those /d are incorrect. You want [0-9] or to use the /a regexp flag on a suitably modern perl.

Re: Finding the intersection between two regexes

2014-04-24 Thread Abigail
On Fri, Apr 25, 2014 at 12:47:04AM +0100, David Cantrell wrote: On 24/04/2014 23:28, Mark Fowler wrote: On Thursday, April 24, 2014, Michael Lush mjl...@gmail.com wrote: if ($x =~ /^246[2-9]\d{6}$/ and $x =~ /^246(?:(?:2[346]|45|82)\d|25[0-4])\d{4}$/ ) Those /d are incorrect. You want

Re: Finding the intersection between two regexes

2014-04-22 Thread David Cantrell
On Sun, Apr 20, 2014 at 10:14:48PM -0400, Mark Fowler wrote: On Sunday, April 20, 2014, David Cantrell da...@cantrell.org.uk wrote: Can anyone point me at some code on the CPAN that, given two regexes, can figure out whether there are any bits of text that will be matched by both? I'm not

Re: Finding the intersection between two regexes

2014-04-22 Thread Paul Makepeace
On Tue, Apr 22, 2014 at 4:16 AM, David Cantrell da...@cantrell.org.uk wrote: On Sun, Apr 20, 2014 at 10:14:48PM -0400, Mark Fowler wrote: On Sunday, April 20, 2014, David Cantrell da...@cantrell.org.uk wrote: Can anyone point me at some code on the CPAN that, given two regexes, can figure

Re: Finding the intersection between two regexes

2014-04-22 Thread Ben Evans
This piece of anecdotal evidence is now a good ~8 years out of date, but I found that there were some surprising performance regressions for a complex, combined regex versus versus multiple runs with simple ones. As ever the moral of the story is, if performance matters, always measure, and get a

Re: Finding the intersection between two regexes

2014-04-21 Thread Dirk Koopman
On 21/04/14 03:14, Mark Fowler wrote: On Sunday, April 20, 2014, David Cantrell da...@cantrell.org.uk wrote: Can anyone point me at some code on the CPAN that, given two regexes, can figure out whether there are any bits of text that will be matched by both? I'm not sure I understand the

Re: Finding the intersection between two regexes

2014-04-21 Thread Kieren Diment
On 21/04/2014, at 6:45 PM, Dirk Koopman d...@tobit.co.uk wrote: This may be related to the question I asked recently about turning (up to) a few hundred REGEXes into one giant REGEX. The goal being to test all those disparate REGEXes in the most efficient way possible on a string. Dirk

Re: Finding the intersection between two regexes

2014-04-21 Thread James Laver
On 21 Apr 2014, at 09:45, Dirk Koopman d...@tobit.co.uk wrote: This may be related to the question I asked recently about turning (up to) a few hundred REGEXes into one giant REGEX. The goal being to test all those disparate REGEXes in the most efficient way possible on a string. Sounds

Re: Finding the intersection between two regexes

2014-04-21 Thread Dirk Koopman
On 21/04/14 10:03, James Laver wrote: On 21 Apr 2014, at 09:45, Dirk Koopman d...@tobit.co.uk wrote: This may be related to the question I asked recently about turning (up to) a few hundred REGEXes into one giant REGEX. The goal being to test all those disparate REGEXes in the most

Finding the intersection between two regexes

2014-04-20 Thread David Cantrell
Can anyone point me at some code on the CPAN that, given two regexes, can figure out whether there are any bits of text that will be matched by both? eg, given /abc.../ and /...def/ it should tell me that there is an intersection, because the string 'abcdef' matches both. I'm not interested in

Re: Finding the intersection between two regexes

2014-04-20 Thread Mark Fowler
On Sunday, April 20, 2014, David Cantrell da...@cantrell.org.uk wrote: Can anyone point me at some code on the CPAN that, given two regexes, can figure out whether there are any bits of text that will be matched by both? I'm not sure I understand the question here, or moreover why you want