2012-09-10 12 views
8

Bu kod:YAPE :: Regex :: Kullanım 5.014 ile çalışmadığını açıklayın;

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

baskılar

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 
---------------------------------------------------------------------- 

ama

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

baskılar sadece bu kodu:

The regular expression: 



matches as follows: 

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

Sorun ne?

+0

ben gerçek bir cevabım yok ama [Normal İfade :: Debugger'ı] denedim (http://search.cpan.org/perldoc?Regexp%3A%3ADebugger)? – stu42j

+1

[unicode_strings özelliği] gibi görünüyor (http://www.perl.com/pub/2011/06/new-features-of-perl-514-unicode-strings.html). "Davranış özelliği" unicode_strings "ile aynı davranışı elde edersiniz; – stu42j

cevap

7

Özellik unicode_strings Özellik, hangi biçimin oluşturulduğunu değiştirir.

$ 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 bakımsızlıktan için birçok yeni (ve böylece yeni değil) özellikleri işleyemez. Bu SINIRLAMALAR bölümünde belgelenmiştir.

Ben (yerine (?^:\d+) ait (?-imsx:d+) görüntüler açıklarken) re::regexp_pattern kullanarak bayrakları alır ve bu konuda bilmiyor "u" bayrağına bobinleri bahis.

$ 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