简体   繁体   English

在Perl中编译正则表达式时“ reg_node overrun”

[英]“reg_node overrun” when compiling regular expressions in perl

I am trying to run a script that defines a few (complex) regular expressions: https://github.com/wo/opp-tools/blob/master/rules/Keywords.pm . 我正在尝试运行定义一些(复杂)正则表达式的脚本: https : //github.com/wo/opp-tools/blob/master/rules/Keywords.pm Whenever I include this module, Perl crashes with the message "panic: reg_node overrun trying to emit 51 at rules/Keywords.pm line 60". 每当我包含此模块时,Perl都会崩溃,并显示消息“ panic:reg_node溢出,试图在rule / Keywords.pm第60行发出51”。 This is with Perl v5.14.2 on Ubuntu 12.04. 这是Ubuntu 12.04上的Perl v5.14.2。 Any ideas what could be the cause of this would be appreciated. 任何想法可能是造成这种情况的原因,我们将不胜感激。

Update: Here is a snippet that causes the problem. 更新:这是导致问题的代码片段。

use strict;
use warnings;
use utf8;

my $re_address_word = qr/\b(?:
universit|center|centre|institute?|sciences?|college|research|
avenue|street|philosophy|professor|address|department|
umass
)\b/ix;

our $re_publication_word = qr/\b(?:
forthcoming|editors?|edited|publish\w*|press|volume
to\sappear\sin|draft|editor\w*|reprints?|excerpt|
circulation|cite
)\b/ix;

my $re_notitle = qr/
$re_address_word |
$re_publication_word |
\b(?:thanks?|
   @|
   [12]\d{3}|
   abstract
)/ix;

our $re_title = qr/^
(?!.*$re_notitle?.*)
\p{IsAlpha}    
/x;

I ran into the same problem today when compiling regular expressions consisting of multiple expression. 今天,在编译由多个表达式组成的正则表达式时遇到了同样的问题。 The example below illustrates the code that generated the problem: 下面的示例说明了生成问题的代码:

    my $cities = qr/(Foo1|Foo2|FooBarss)/;
    ## Solution change ss -> s[s]
    ## my $cities = qr/(Foo1|Foo2|FooBars[s])/;
    my $street = qr/(foo|bar|baz)/;

    $text =~ /$street \s+ $cities/;

The solution was to replace literal ss with s[s], it seems pretty random and I cannot dig up the reference to support it but it works for me. 解决的办法是用s [s]替换文字ss,这似乎是随机的,我无法挖掘支持它的引用,但对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM