8

このコード:

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

どうしたの?

4

1 に答える 1

7

unicode_stringsどのパターンが作成されるかはフィーチャーによって異なります。

$ 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は、メンテナンスが不足しているため、多くの新しい (そしてそれほど新しくない) 機能を処理できません。これは、制限セクションに記載されています。

を使用してフラグを取得し( の代わりにre::regexp_pattern表示する理由を説明します)、知らない" " フラグでチョークするに違いありません。(?-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
于 2012-09-10T21:22:42.027 に答える