2012-09-10 12 views
8

este código:YAPE :: Regex :: Explain no funciona con el uso 5.014;

use strict; 
use warnings; 
use YAPE::Regex::Explain; 
print YAPE::Regex::Explain->new(qr/d+/)->explain(); 

impresiones

The regular expression: 

(?-imsx:d+) 

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): 
---------------------------------------------------------------------- 
    d+      'd' (1 or more times (matching the most 
          amount possible)) 
---------------------------------------------------------------------- 
)      end of grouping 
---------------------------------------------------------------------- 

pero este código sólo

use 5.014; #added this 
use strict; 
use warnings; 
use YAPE::Regex::Explain; 
print YAPE::Regex::Explain->new(qr/d+/)->explain(); 

impresiones:

The regular expression: 



matches as follows: 

NODE      EXPLANATION 
---------------------------------------------------------------------- 

¿Qué ocurre?

+0

no tengo una respuesta real, pero he intentado [Regexp :: depurador] (http://search.cpan.org/perldoc?Regexp%3A%3ADebugger)? – stu42j

+1

Parece ser la característica [unicode_strings] (http://www.perl.com/pub/2011/06/new-features-of-perl-514-unicode-strings.html). Obtienes el mismo comportamiento con 'use feature 'unicode_strings';' – stu42j

Respuesta

7

Función unicode_strings cambia qué patrón se crea.

$ perl -le'no feature qw(unicode_strings); print qr/\d+/' 
(?^:\d+) 

$ perl -le'use feature qw(unicode_strings); print qr/\d+/' 
(?^u:\d+) 

YAPE::Regex::Explain no puede manejar muchos de los nuevos (y no tan nuevo) presenta debido a la falta de mantenimiento. Esto está documentado en la sección de LIMITACIONES.

apuesto se pone las banderas utilizando re::regexp_pattern (que explica por qué se muestra (?-imsx:d+) en lugar de (?^:\d+)), y se ahoga con el "u" bandera que no sabe nada.

$ perl -le'no feature qw(unicode_strings); print +(re::regexp_pattern(qr/\d+/))[1]' 


$ perl -le'use feature qw(unicode_strings); print +(re::regexp_pattern(qr/\d+/))[1]' 
u 
Cuestiones relacionadas