Skip Menu |

This queue is for tickets about the YAPE-Regex-Explain CPAN distribution.

Report information
The Basics
Id: 28466
Status: open
Priority: 0/
Queue: YAPE-Regex-Explain

People
Owner: Nobody in particular
Requestors: RENEEB [...] cpan.org
Cc:
AdminCc:

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



Subject: Y::R::E can't handle \Q ... \E
As an example: #!/usr/bin/perl use strict; use warnings; use YAPE::Regex::Explain; my $re = '\Q[\E'; print YAPE::Regex::Explain->new($re)->explain; prints: The regular expression: matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- \Q 'Q' ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
From: gsullivan [...] cpan.org
On Wed Jul 25 06:19:17 2007, RENEEB wrote: Show quoted text
> As an example: > > #!/usr/bin/perl > > use strict; > use warnings; > use YAPE::Regex::Explain; > > my $re = '\Q[\E'; > print YAPE::Regex::Explain->new($re)->explain; > > prints: > > > The regular expression: > > > > matches as follows: > > NODE EXPLANATION > ---------------------------------------------------------------------- > (?-imsx: group, but do not capture (case-sensitive) > (with ^ and $ matching normally) (with . not > matching \n) (matching whitespace and # > normally): > ---------------------------------------------------------------------- > \Q 'Q' > ---------------------------------------------------------------------- > ) end of grouping > ----------------------------------------------------------------------
In my opinion, this is not a bug. It can handle \Q\E if the qr// operator is used to compile the regular expression before passing it to the constructor: my $re = qr/\Q[\E/; This usage model is illustrated in the POD for YAPE::Regex. use strict; use warnings; use YAPE::Regex::Explain; my $re = qr/\Q[\E/; print YAPE::Regex::Explain->new($re)->explain; __END__ prints: The regular expression: (?-imsx:\[) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- \[ '[' ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
On Wed Jul 25 06:19:17 2007, RENEEB wrote: Show quoted text
> As an example: > > #!/usr/bin/perl > > use strict; > use warnings; > use YAPE::Regex::Explain; > > my $re = '\Q[\E'; > print YAPE::Regex::Explain->new($re)->explain; > > prints: > > > The regular expression: > > > > matches as follows: > > NODE EXPLANATION > ---------------------------------------------------------------------- > (?-imsx: group, but do not capture (case-sensitive) > (with ^ and $ matching normally) (with . not > matching \n) (matching whitespace and # > normally): > ---------------------------------------------------------------------- > \Q 'Q' > ---------------------------------------------------------------------- > ) end of grouping > ----------------------------------------------------------------------
<< \Q[\E >> is not a valid regex pattern. << \Q >> and << \E >> are unknown escapes (treated as << Q >> and << E >>), but more importantly, << [ >> is unmatched. $ perl -we'$re=q{\Q[\E}; qr/$re/' Unmatched [ in regex; marked by <-- HERE in m/\Q[ <-- HERE \E/ at -e line 1. << \Q >> and << \E >> are significant double-quoted string literals and in regex literals, but you have neither here. You built your pattern using a single-quoted string literal.
Why doesn't Y::R::E say the pattern is invalid? I consider that a bug.