cancel
Showing results for 
Search instead for 
Did you mean: 

RegEx for Cisco interface

RegEx for Cisco interface

StephanH
Valued Contributor III

Hello,

for the comliance engine I have to find all interfaces not have a certain command line.

Here is a positive an a negativ example:

interface GigabitEthernet1/0/48
 description Test1
 switchport access vlan 830
 switchport mode access
 switchport voice vlan 310
 no cdp enable
!
interface GigabitEthernet1/0/49
 description Test2
 switchport mode trunk
 switchport nonegotiate
 queue-set 2
 mls qos trust dscp
 channel-group 1 mode active
 ip dhcp snooping trust

!

I am looking for an regex matching the hole interface 1/0/48 and NOT the interface 1/0/49.

The criterion should be, that all interfaces are found in which “mls qos trust dscp” is NOT present.

 

I tried  interface GigabitEthernet\d{1,2}\/\d{1,2}\/\d{1,2}[\s\n\w-].*?(?:(?<!mls qos trust dscp)[\s\n\w-])*?! but this regex match all interfaces and not only the 1/0/48.  But this is not working.

 

Any ideas?

Regards Stephan
1 ACCEPTED SOLUTION

StephanH
Valued Contributor III

Hello Mig,

your assumption was right, the compliance check does not support multiline regex, this is function as designed. This was the offical answer from GTAC.

 

Regards Stephan

View solution in original post

5 REPLIES 5

Miguel-Angel_RO
Valued Contributor II

Hi Stephan,

I think you’ll have to open a case at GTAC.

From my understanding the compliance engine will use python in the background and they seem to have the global flag active for the regex. This flag cannot be deactivated from within the regex.

Look at the following screenshots activting/deactivating the global flag:

a6448572b0874fa694b44f836a102f04_3ff52232-82bc-4333-b86b-74f2c91f0740.png
a6448572b0874fa694b44f836a102f04_63a935a5-5a7f-46fc-9c3e-8c2d3fb4de81.png

Mig

GTM-P2G8KFN