Skip Menu |

This queue is for tickets about the Regexp-Debugger CPAN distribution.

Report information
The Basics
Id: 117199
Status: new
Priority: 0/
Queue: Regexp-Debugger

People
Owner: Nobody in particular
Requestors: cmcdona2 [...] tcd.ie
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Recursive Regex save_to only writes the first match
Date: Wed, 24 Aug 2016 22:17:02 +0100
To: bug-Regexp-Debugger [...] rt.cpan.org
From: Colin McDonagh <cmcdona2 [...] tcd.ie>
Hi, Sorry for the flurry of emails. I was just wondering if I'm on to something here. When I execute the command 'perl -e "use Regexp::Debugger save_to => \"regex_debugged.json\"; 'aaazzz' =~ /a(?R)?z/' the match_data only includes up to the first match... matched within 17 steps. Your help in this regards would be kindly appreciated. Best regards, Colin McDonagh -- *Colin McDonagh*
Subject: Re: Recursive Regex save_to only writes the first match
Date: Wed, 24 Aug 2016 22:44:39 +0100
To: bug-Regexp-Debugger [...] rt.cpan.org
From: Colin McDonagh <cmcdona2 [...] tcd.ie>
There is an error in executing this command as well: stderr: Syck parser (line 1, column 293): syntax error at /Library/Perl/5.18/Regexp/Debugger.pm On 24 August 2016 at 22:17, Colin McDonagh <cmcdona2@tcd.ie> wrote: Show quoted text
> Hi, > > Sorry for the flurry of emails. > > I was just wondering if I'm on to something here. > > When I execute the command 'perl -e "use Regexp::Debugger save_to => > \"regex_debugged.json\"; 'aaazzz' =~ /a(?R)?z/' the match_data only > includes up to the first match... matched within 17 steps. > > Your help in this regards would be kindly appreciated. > > Best regards, > > Colin McDonagh > > -- > *Colin McDonagh* >
-- *Colin McDonagh*
Subject: Re: [rt.cpan.org #117201] Re: Recursive Regex save_to only writes the first match
Date: Thu, 25 Aug 2016 13:14:02 +1000
To: bug-Regexp-Debugger [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Hi Colin, Handling of the (?R) construct is problematic, since the regex engine literally re-executes the entire regex including the Regexp::Debugger set-up code. It may be possible to fix that behaviour, but it won't be trivial and I won't be able to do so in the near future. For the time being, I recommend avoiding the (?R) construct if you need to debug using Regexp::Debugger. For instance, your example could be rewritten: /(?&AZ) (?(DEFINE) (?<AZ> a (?&AZ)? z ))/x This is how I write all my non-trivial regexes nowadays: effectively as a single "call" to a sub-pattern like (?&AZ), followed by a (?(DEFINE)...) block in which the various components are defined. Regexp::Debugger definitely handles that approach correctly. Indeed, when it comes to fixing the handling of (?R) I will probably do so by wrapping the entire regex in a single "call" of this nature. That is: /a (?R)? z/x will first be converted to: /(?&R) (?(DEFINE) (?<R> a (?&R)? z ))/x before the debugging code is inserted. But, as I mentioned before, that's a non-trivial amount of work, so it will have to wait until I have the spare time to look at it properly. Thanks for the report, and sorry I can't offer a quicker or simpler solution. Damian
Subject: Re: [rt.cpan.org #117201] Re: Recursive Regex save_to only writes the first match
Date: Thu, 25 Aug 2016 08:40:13 +0100
To: bug-Regexp-Debugger [...] rt.cpan.org
From: Colin McDonagh <cmcdona2 [...] tcd.ie>
Hi Damian, Thanks for the quick reply back. That makes a lot of sense. Yeah of course, in time possibly.. If I can help in any way let me know. Best regards, Colin On 25 Aug 2016 04:15, "damian@conway.org via RT" < bug-Regexp-Debugger@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=117201 > > > Hi Colin, > > Handling of the (?R) construct is problematic, since > the regex engine literally re-executes the entire regex > including the Regexp::Debugger set-up code. It may > be possible to fix that behaviour, but it won't be trivial > and I won't be able to do so in the near future. > > For the time being, I recommend avoiding the (?R) > construct if you need to debug using Regexp::Debugger. > For instance, your example could be rewritten: > > /(?&AZ) (?(DEFINE) (?<AZ> a (?&AZ)? z ))/x > > This is how I write all my non-trivial regexes nowadays: > effectively as a single "call" to a sub-pattern like (?&AZ), > followed by a (?(DEFINE)...) block in which the various > components are defined. > > Regexp::Debugger definitely handles that approach correctly. > Indeed, when it comes to fixing the handling of (?R) I will > probably do so by wrapping the entire regex in a single > "call" of this nature. > > That is: > > /a (?R)? z/x > > will first be converted to: > > /(?&R) (?(DEFINE) (?<R> a (?&R)? z ))/x > > before the debugging code is inserted. > > But, as I mentioned before, that's a non-trivial amount of work, > so it will have to wait until I have the spare time to look at it properly. > > Thanks for the report, and sorry I can't offer a quicker or simpler > solution. > > Damian > >