I'm need help figuring out a RegEx statement to help me match properly interfaces on a switch/router.
Example: Correct matches may be:
Fa1/0, Gig2/0/2, Fa3/0/33/333, G1/0/0:1, Gi0/0.900 etc.
The closest I've been able to get is:
[fget][a-z]*[0-9]+(?:[\/\.:][0-9]+)+
The problem is that is also matches the Fa1/0
part of Fa1/0/
or Fa1/0a
which is incorrect and shouldn't be matched at all.
Can anyone assist me?
Given the string: Start Fa1/0/1 Gig2/0 Fa1/0/ Ending
Match ONLY: Fa1/0/1
and Gi2/0
Restriction: You cannot use: \s
or ' '
(the parser I'm using doesn't allow it)
Modifier: Case is set to insensitive.
ADDITIONAL INFO/EDIT BELOW
This is actually for a RegEx parser that is in the new SecureCRT 7.3 terminal application.
The goal is to colorize proper syntax in real time, while removing colorization from improper syntax.
That is why we can't depend on the ^ and $ tokens, because you can never be assured the word will be at the start or ending of the line.
Properly matched whole words will follow the format of: Interface-Type + Number + Sub-interface (optional).
Interface-Type: Could be anything from 'F' to FastEthernet. Other prefixes include 'g' to Gigabit, 'e' to Ethernet, and 't' to ten.
Number: This will follow the pattern of and then (repeating). Example: 1/2 or 1/2/3 or even 1/2/3/4/5/6/7/8/10/12 would technically be valid for this case.
Sub-interface (Optional): Would follow the format of or . IE: .900 or :123
So, more string examples could be: F1/0/1.900 Gig2/0 Te1/0/0/1:23 The words could appear in any order and mixed many other words. IE: "Show Int F1/0/0" or "int Range fa1/0/1 - 24"