regex - 为什么我不能连接在 qr 下编译和运行时评估的模式?

标签 regex perl

为什么这颗炸弹

perl -e 'print qr{$_(??{$_})}'

虽然这两者是分开工作的:

perl -e 'print qr{$_}'
perl -e 'print qr{(??{$_})}'

错误信息是

Eval-group not allowed at runtime, use re 'eval' in regex m/(??{$_})/ at -e line 1.

真的,我应该升级 Perl 吗?我有5.14.4。

最佳答案

这是 5.18.0 中修复的错误和5.17.1

The implementation of code blocks in regular expressions, such as (?{}) and (??{}), has been heavily reworked to eliminate a whole slew of bugs. The main user-visible changes are:

  • Code blocks within patterns are now parsed in the same pass as the surrounding code;

  • Lexical variables are now sane as regards scope, recursion and closure behavior.

关于regex - 为什么我不能连接在 qr 下编译和运行时评估的模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19551918/

相关文章:

perl - 如何告诉 perl 模块的路径?

python - 没有在 Python 中分组的正则表达式和 OR 运算符?

javascript - 如何使用类似于 PHP 的 preg_match_all() 的 JavaScript 中的正则表达式匹配多次出现?

javascript - 字符串用正则表达式分割,返回完全匹配的数组

perl - 打印 $/而不是\n 是错误的吗?

arrays - 当我 grep 数组时,如何获取元素的索引?

python - 使用 Python 从目录和文件中删除反斜杠

regex - 在 AngularJS ui-router 中匹配一个或另一个词

perl - 就地编辑时读取整个文件然后打印?

perl - 如何判断网页是否存在?