The regex you are using does not anchor to the end.
use strict; use warnings; use Test::More tests => 4; my $tomatch = 'GigabitEthernet1/0/48'; my $notmatch = 'GigabitEthernet1/0/49'; my $yourgo = qr/(^gi.*)([1-8])(\/)(0)(\/)([1-9]|[1-3][0-9]|4[0-8])/i; my $mygo = qr/(^gi.*)([1-8])(\/)(0)(\/)([1-9]|[1-3][0-9]|4[0-8])$/i; like ($tomatch, $yourgo, "$tomatch matches"); unlike ($notmatch, $yourgo, "$notmatch does not match"); like ($tomatch, $mygo, "$tomatch matches"); unlike ($notmatch, $mygo, "$notmatch does not match");
There's other things you could clean up in the regex and your stipulation of not using a numerical comparison requires justification but this should put you on the right road at least.
In reply to Re: Regex : Limit value of a string
by hippo
in thread [SOLVED] Regex : Limit value of a string
by PtitePomme
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |