What I am trying to do is given a string like :
"hello GigabitEthernet1/13 mplampla"
to extract the interface, for example:
"GigabitEthernet1/13"
and to extract the first 2 characters and then the interface number, for example:
"Gi1/13"
What I am doing wrong ?
#!/usr/bin/perl -w
use strict ;
use warnings ;
my $string = "hello GigabitEthernet1/13 mplampla" ;
$string =~ /(^[a-z]{2}*[0-9]\/*[0-9]*\/*[0-9]*)/ ;
print $string."\n" ;
PS. the interface number can be like “Po4“, “TenGigabitEthernet2/0/0.13“, etc.
One way:
The regex:
For printing: