laziness, impatience, and hubris | |
PerlMonks |
Re: [SOLVED] Regex : Limit value of a stringby johngg (Canon) |
on Oct 14, 2015 at 14:46 UTC ( [id://1144868]=note: print w/replies, xml ) | Need Help?? |
I don't think any of the proposed solutions will reject GigabitEthernet31/0/23 as the (^gi.*)([1-8]), ^(gi.*)([1-8]) or ^ (gi [^/]*) ([1-8]) will all capture GigabitEthernet3 into $1 and 1 into $2. You need to anchor the start of the first digit as well as the end of the last. Also simpler to construct the regex using a range and locally setting $".
I hope this is helpful. Cheers, JohnGG
In Section
Seekers of Perl Wisdom
|
|