首页 > 试题广场 >

已知$str="Regular matching in pr

[单选题]

已知$str="Regular matching in progress";,仔细观察下列两个Perl程序,请问输出的选项一致吗,选出正确的选项。

程序1
$str =~ qr/m.*g/;
print "$&";
程序2
$match=qr/m.*g/;
$str =~ $match;

$str =~ /$match/;
print "$&";

  • 不一致,程序1输出为matching in prog,程序2输出为matching in progress

  • 不一致,程序1输出为matching in progress,程序2输出为matching in prog

  • 一致,输出均为matching in prog

  • 一致,输出均为matching in progress

这道题你会答吗?花几分钟告诉大家答案吧!