IOS / XE
NX-OS
Test it
Result, highlighted lines are kept
Cisco regex on one card
_A space, comma, bracket, or the start or end of the line. Not an underscore.
^ $Start and end of the line. ^_ matches a line that starts with a space.
.Any one character, including a real underscore.
[1-9][0-9]*Any number that is not zero. The trick behind the "not zero" match.
a|bEither. IOS takes one filter per command, so put every alternative in one expression.
( )Group alternatives: Gi7/(29|3[0-9])_ is ports 29 to 39.
Ctrl+V ?Type Ctrl+V before ? or the CLI shows help instead.
CaseFilters are case-sensitive. On NX-OS, egrep -i ignores case.