YAPE::Regex::Explain 不适用于 use 5.014; [英] YAPE::Regex::Explain not working with use 5.014;

查看:57
本文介绍了YAPE::Regex::Explain 不适用于 use 5.014;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码:

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

怎么了?

推荐答案

Feature unicode_strings 更改创建的模式.

Feature unicode_strings changes which pattern gets created.

$ 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 无法处理许多新的(和不是那么新)功能由于缺乏维护.这在限制部分有记录.

YAPE::Regex::Explain can't handle many new (and not so new) features due to lack of maintenance. This is documented in the LIMITATIONS section.

我敢打赌它使用 re::regexp_pattern 获取标志(解释为什么它显示 (?-imsx:d+) 而不是 (?^:\d+)),并在它不知道的u"标志上窒息.

I bet it gets the flags using re::regexp_pattern (explaining why it displays (?-imsx:d+) instead of (?^:\d+)), and chokes on the "u" flag it doesn't know about.

$ 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

这篇关于YAPE::Regex::Explain 不适用于 use 5.014;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆