regex - Perl regexp matching -
edit : have difficult express myself. let me start again. have loop read string file :
gigabitethernet0/0 gigabitethernet0/1 gigabitethernet0/2 serial0/0/0:0 serial0/0/0:0.100
and i'm trying regexp interface serial0/0/0:0
if ($linesplitter[2] =~ /serial0(.*):0[^(.\d)](.*)/ && $interfacebool eq "false"){ $interfaceneeded = $linesplitter[2] ; }
but not working. tried several things on online regexp simulator still.. without result... want main interface (serial0/0/0:0), not sub-interface (serial0/0/0:0.100)
expected variable:
serial0/0/0:0
i don't want replace, or part of sub-interface. want regexp match main interface without matching sub-one
sorry misunderstanding.
if want restrict match, use anchors, ^
match beginning of string, , $
match end of string:
/^serial0(.*):0$/
this match serial
strings end :0
.
Comments
Post a Comment