perl正则表达式中,\Q用于是元字符常量化,例如
C:\Perl\bin>perl
$what = "[box]";
foreach (qw(in[box] out[box] white[sox])) {
if (/\Q$what\E/) {
print "$_ matched!\n";
}
}
^D
in[box] matched!
out[box] matched!
C:\Perl\bin>perl
$what = "[box]";
foreach (qw(in[box] out[box] white[sox])) {
if (/$what\E/) {
print "$_ matched!\n";
}
}
^D
in[box] matched!
out[box] matched!
white[sox] matched!
阅读(767) | 评论(0) | 转发(0) |