且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

perl 正则表达式中缺少最后一个字符

更新时间:2022-05-20 22:38:32

看起来你的 .* 应该是 [^)]*,即 *任意数量的不是右括号的字符.给予

It looks like your .* should be [^)]*, i.e. *any number of characters that are not closing parentheses. Giving

^\(log ([^)]*)\)\s*\(log ([^)]*)\)$

或者你可以用

while ( $s =~ /\(log ([^)]*)\)/g ) {
    print $1, "\n";
}