12-30-2015 08:50 AM - edited 12-30-2015 11:54 AM
While working with CCS on the NetMRI platform, I noticed that the following Regex:
would not match an interface named:
I modified the regex to:
and now it's matching properly for the following test cases:
GigabitEthernet323230/43434354/545454230/4545450 (Yeah, that too.)
The only problem I seem to run into is with the following:
the last "/4" never gets matched. Thankfully, I don't have to worry about it in my current environment, but that doesn't preclude me from finding a solution.
Has anyone come up with a more comprehesive pattern?
Solved! Go to Solution.
03-02-2016 04:14 PM - edited 03-02-2016 07:03 PM
Maybe something like
would work? In Human, that's
Any word, optionally hyphenated with another word, followed by some digits, optionally followed by one or more repetitions of either a "/" or a ":" followed by digits, optionally followed by a "." and some digits.
...so it'll match regardless of how many interface "levels" there are, and only allows the "dot subinterface" to be in the last grouping. So it'll match GigabitEthernet0/1/14.42, but not GigabitEthernet0/1.5/42.
That matches all the interface names on your list, including "GigabitEthernet0/1/2/3/4", and would also match "GigabitEthernet0/1/2/3/4/5/6/7/8/9". :-)
It will also match a few constructs that may not technically be legal interface names, since it will allow for digits separated by a colon in any position, not only after the second slash like yours did. Not sure if that's likely to be an issue?