在Perl中需要帮助模式匹配

时间:2015-06-13 05:30:22

标签: regex perl pattern-matching

如何进行模式匹配" Iface名称:bnx2i.00:17:a4:77:14:2f"究竟?之前和之后不应有空格或新行。

1 个答案:

答案 0 :(得分:0)

my $if = "Iface Name: bnx2i.00:17:a4:77:14:2f";
if ($if =~ /^Iface Name: ([a-f0-9]+\.(?:[a-f0-9]{2}:){5}[a-f0-9]{2})\z/) {
   print $1;
}