cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1551
Views
15
Helpful
6
Replies

# REGEX in CISCO iOS, iOS XE #

Hi,

REGULAR EXPRESSION, a filtring tool based on ::
Special characters, Characters classes, Sets, Groups, Flags.
are all these ASPECTS availible in cisco iOS, iOS XE ?
is there other unknown characters  like underscore "_" ?
Best Regards!

6 Replies 6

Giuseppe Larosa
Hall of Fame
Hall of Fame

Hello,

yes regular expressions are available in IOS, IOS XE and IOS XR and NX-OS.

 

There are  two main applications for regular expresssion in IOS:

 

a)  Filtering BGP advertisements using regular expressions applied to the AS path attribute seen as a sequence of characters

see

https://www.cisco.com/c/en/us/support/docs/ip/border-gateway-protocol-bgp/13754-26.html?dtid=osscdc000283

 

b) using regular expressions in show commands to filter show output.

https://learningnetwork.cisco.com/s/question/0D53i00000KssVx/regular-expression-in-cisco-show-commands?dtid=osscdc000283

 

 

Hope to help

Giuseppe

Hi,

i'm using regex to filter show commands this time !. it works almost fine, just for some cases ::

* the digits specification \d does not work
* how to escape characters  \.
* how to use ?=non-greedy as it is considered as help on cisco iOS
* is it possible to provide an underscore "_" exemples !


best regards!

Hello,

in order to make the regex to search for a special character "literally" the character has to have a \ before

 

show ip int br  | inc   gigabitethernet0/0/0\.*

 

should show all subinterfaces of gigabitethernet0/0/0.

 

This trick should work also for '_' underscore to match it literally try to use \_

 

Hope to help

Giuseppe

 

Leo Laohoo
Hall of Fame
Hall of Fame

Please be very, very careful when dealing with IOS-XE and REGEX, particularly the "pipe".  This is due to CSCvo06817.

Hi,

 

using grep after the terminal shell command, does is offer more advantages or it's the same as |Pipe include ...

best regards!

"grep" option only works for Nexus OS.  The bug I've pointed out is for IOS-XE.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Innovations in Cisco Full Stack Observability - A new webinar from Cisco