YAPE::Regex::解释不使用use 5.014;
此代码:YAPE::Regex::解释不使用use 5.014;,regex,perl,Regex,Perl,此代码: use strict; use warnings; use YAPE::Regex::Explain; print YAPE::Regex::Explain->new( qr/d+/ )->explain(); 印刷品 The regular expression: (?-imsx:d+) matches as follows: NODE EXPLANATION --------------------------------
use strict;
use warnings;
use YAPE::Regex::Explain;
print YAPE::Regex::Explain->new( qr/d+/ )->explain();
印刷品
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
----------------------------------------------------------------------
但是这个代码
use 5.014; #added this
use strict;
use warnings;
use YAPE::Regex::Explain;
print YAPE::Regex::Explain->new( qr/d+/ )->explain();
仅打印:
The regular expression:
matches as follows:
NODE EXPLANATION
----------------------------------------------------------------------
怎么了?功能
unicode\u字符串
更改了创建的模式
$ perl -le'no feature qw( unicode_strings ); print qr/\d+/'
(?^:\d+)
$ perl -le'use feature qw( unicode_strings ); print qr/\d+/'
(?^u:\d+)
由于缺乏维护,无法处理许多新功能(而且不是很新)。这在“限制”一节中有记录
我打赌它使用re::regexp_模式
(解释为什么它显示(?-imsx:d+
)而不是(?^:\d+
)来获取标志,并阻塞它不知道的“u
”标志
$ 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
我没有一个实际的答案,但你试过了吗?似乎是最好的答案。使用
功能“unicode_字符串”时,您会得到相同的行为代码>