未转义的左括号正则表达式错误 [英] Unescaped left brace regex error
问题描述
我不是正则表达式方面的专家,无法弄清楚我应该在这里更改什么.
I’m not an expert in regex and can't figure what I am supposed to change here.
我收到这两个错误
regex 中未转义的左大括号已弃用,在 regex 中传递;在 m/^(.*?)(\\)?\${ <-- HERE ([^{}]+)}(.*)$/
在/usr/share/perl5/Debconf/Question.pm 第 72 行.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE
in m/^(.*?)(\\)?\${ <-- HERE ([^{}]+)}(.*)$/
at /usr/share/perl5/Debconf/Question.pm line 72.
不推荐使用正则表达式中未转义的左大括号,在正则表达式中传递;由 <-- HERE
标记在 m/\${ <-- HERE ([^}]+)}/
at/usr/share/perl5/Debconf/Config.pm 第 30 行.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE
in m/\${ <-- HERE ([^}]+)}/
at /usr/share/perl5/Debconf/Config.pm line 30.
当我跳到第 72 行时,这是我看到的
When I jump to the line 72 this is what I see
while ($rest =~ m/^(.*?)(\\)?\${([^{}]+)}(.*)$/sg) {
推荐答案
这是一个弃用的警告,表明代码将在未来停止工作.
It's a deprecation warning indicating the code will stop working in the future.
如果你想从字面上匹配 {
,你应该转义它.
If you want to match a {
literally, you should escape it.
换句话说,您可以通过将第一个 {
替换为 \{
来解决问题(消除警告).
In other words, you can fix the issue (silencing the warning) by replacing the first {
with \{
.
这篇关于未转义的左括号正则表达式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!