2
我从Jeffrey Friedl的书Mastering Regular Expressions 3rd Ed。(page 167)运行我的perl脚本时遇到以下错误,任何人都可以帮助我??序列(?在正则表达式中不完整 - 负查找
错误消息:?
序列(在正则表达式不完整的;标记为< - 这里以m/ ( ( (< - HERE /通过/ home/wubin28/mastering_regex_cn/p167.pl line 13.
我的perl脚本
#!/usr/bin/perl
use 5.006;
use strict;
use warnings;
my $str = "<B>Billions and <B>Zillions</B> of suns";
if ($str =~ m!
(
<B>
(
(?!<B>) ## line 13
.
)*?
</B>
)
!x
) {
print "\$1: $1\n"; #output: <B>Billions and <B>Zillions</B>
} else {
print "not matched.\n";
}
明白了。非常感谢! –
你也可以逃脱! (\!)里面的正则表达式,如果你想使用m!句法 –