Need help in pattern matching in Perl

62 Views Asked by At

How to do the pattern match of "Iface Name: bnx2i.00:17:a4:77:14:2f" exactly? There should not be spaces or new lines before and after.

1

There are 1 best solutions below

1
On BEST ANSWER
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;
}