Perl中,表达式"(... (*ACCEPT) ...)+"永远不会匹配。

6

来自 perlre 的文档:

If the "(*ACCEPT)" is inside of capturing groups then the groups are marked as ended at the point at which the "(*ACCEPT)" was encountered. For instance:

  'AB' =~ /(A (A|B(*ACCEPT)|C) D)(E)/x;

will match, and $1 will be "AB" and $2 will be "B" ...

然而,如果第二个捕获组有一个量词符号,该模式将永远不匹配:
'AB' =~ /(A (A|B(*ACCEPT)|C)+ D)(E)/x or die "No match";  #dies
                            ^

为什么会这样呢?将 + 替换为 * 或 {0,99} 并没有任何区别。任何一个包含(*ACCEPT) 的捕获组上加量词似乎都会阻止 *ACCEPT 的工作。非常感谢您的帮助。


它甚至都不匹配ABDE - ikegami
看起来这是一个Perl相关问题,因为PCRE / PCRE2 没有问题报告 - Wiktor Stribiżew
2
Reported - ikegami
即将发布的5.36版本中已修复。 - ikegami
1个回答

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接