mpenning / ciscoconfparse

Parse, Audit, Query, Build, and Modify Arista / Cisco / Juniper / Palo Alto / F5 configurations.
http://www.pennington.net/py/ciscoconfparse/
GNU General Public License v3.0
793 stars 220 forks source link

Ignores Excludes Regex syntax #175

Closed jm7647 closed 4 years ago

jm7647 commented 4 years ago

By definition Python allows exclusions:

     [^ab5] | Adding ^ excludes any character in the set

From my experience I can't exclude anything using CiscoConfParse.

mpenning commented 4 years ago

Please consider altering your negative regex... I think this does what you want:


>>> from ciscoconfparse import CiscoConfParse

>>> parse = CiscoConfParse(['thing 1', 'thing 3', 'thing 5'])
>>> parse.find_objects(r'^[^ab5]+$')  # When excluding characters it helps to match the line
[<IOSCfgLine # 0 'thing 1'>, <IOSCfgLine # 1 'thing 3'>]