Note: This issue is to openly discuss the possible change and any drawbacks/concerns. As noted below, I have a fix for it and will gladly submit a PR.
TEMPLATE USING
Value PORT (\S+)
Value NAME (.+?)
Value DOWNTIME ((00:00:00)|(([0-9]{1,2} year[s]? , )?([0-9]{1,2} week[s]?, )?([0-9]{1,2} day[s]?, )?([0-9]{1,2} hour[s]?, )?([0-9]{1,2} minute[s]? )?([0-9]{1,2} secs))|((([0-9]{1,2}y)?([0-9]{1,2}w)?([0-9]{1,2}d)([0-9]{1,2}h)?|[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2})))
Value SINCE (.+?)
Value UPTIME ((([0-9]{1,2}m)?([0-9]{1,2}w)?([0-9]{1,2}d)|[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}))
Start
^\s*\^\s* -> EOF
^.*Invalid input detected.* -> EOF
^Load\s+for\s+
# Capture time-stamp if vty line has command time-stamping turned on
^Time\s+source\s+is
^-+\s*$$
^\s*Port\s+Name\s+Down Time\s+Down Since\s*$$ -> DownSince
^\s*Port\s+Name\s+Down Time\s+Up Time\s*$$ -> UpTime
^\s*$$
^. -> Error
DownSince
^\s*${PORT}\s+${DOWNTIME}\s*$$ -> Record
^\s*${PORT}\s+${DOWNTIME}\s*${SINCE}\s*$$ -> Record
^\s*${PORT}\s+${NAME}\s*${DOWNTIME}\s*$$ -> Record
^\s*${PORT}\s+${NAME}\s*${DOWNTIME}\s+${SINCE}\s*$$ -> Record
^\s*$$
^. -> Error
UpTime
^\s*${PORT}\s+${NAME}\s+00:00:00\s+${UPTIME}?\s*$$ -> Record
^\s*${PORT}\s+${DOWNTIME}\s+${UPTIME}?\s*$$ -> Record
^\s*${PORT}\s+${NAME}\s+${DOWNTIME}\s*$$ -> Record
^\s*$$
^. -> Error
SAMPLE COMMAND OUTPUT
Port Name Down Time Up Time
Te5/0/1 43w5d
Fo5/0/9 43w5d
Fo5/0/10 43w5d
Twe5/0/1 L3 Link 00:00:00 9w4d
Twe5/0/1.602 L3 Link VR 00:00:00 9w4d
Twe5/0/1.603 L3 Link VRF 00:00:00 9w4d
Twe5/0/5 43w5d
Ap5/0/1 43w5d
Te6/0/1 43w5d
Fo6/0/9 43w5d
Fo6/0/10 43w5d
Twe6/0/1 L3 Link 00:00:00 9w4d
Twe6/0/1.602 L3 Link VR 00:00:00 9w4d
Twe6/0/1.603 L3 Link VRF 00:00:00 9w4d
Twe6/0/5 43w5d
SUMMARY
While working on issue #1605, I noticed that the NAME capture group matches a single space when there is no visible name/description present. Ideally if there is no visible name then no characters should be matched and thus a zero length empty string would be returned. This has programming benefits when it comes to conditional logic.
Ideally if there is no visible name then no characters should be matched and thus a zero length empty string would be returned. This has programming benefits when it comes to conditional logic.
:bulb: This can easily be remedied by adjusting the NAME regex as shown below.
:tada: I will gladly submit a PR once any drawbacks/concerns have been voiced.
Value NAME (.*?)
ACTUAL RESULTS
A single space was matched for the NAME capture group.
ISSUE TYPE
Note: This issue is to openly discuss the possible change and any drawbacks/concerns. As noted below, I have a fix for it and will gladly submit a PR.
TEMPLATE USING
SAMPLE COMMAND OUTPUT
SUMMARY
While working on issue #1605, I noticed that the
NAME
capture group matches a single space when there is no visible name/description present. Ideally if there is no visible name then no characters should be matched and thus a zero length empty string would be returned. This has programming benefits when it comes to conditional logic.STEPS TO REPRODUCE
EXPECTED RESULTS
Ideally if there is no visible name then no characters should be matched and thus a zero length empty string would be returned. This has programming benefits when it comes to conditional logic.
:bulb: This can easily be remedied by adjusting the
NAME
regex as shown below. :tada: I will gladly submit a PR once any drawbacks/concerns have been voiced.Value NAME (.*?)
ACTUAL RESULTS
A single space was matched for the
NAME
capture group.