Cisco modes match this, but not

I have the following line in a much larger configuration:

as-path-set DAVE-9999-CBG
as-path-set DAVE-9999-CBG
as-path-set DAVE-55555-CBG
as-path-set DAVE-44444-CBG
as-path-set DAVE-33333-CBG
as-path-set DAVE-11111-CBG
as-path-set DAVE-22222-CBG

I would like to match all of these lines except for lines containing 9999. I do not understand the regex negation well enough to make this work. Can someone help. The ideal solution would be:

as-path-set DAVE-55555-CBG
as-path-set DAVE-44444-CBG
as-path-set DAVE-33333-CBG
as-path-set DAVE-11111-CBG
as-path-set DAVE-22222-CBG
+4
source share
2 answers

You can use a negative view:

^as-path-set DAVE-(?!9999)[0-9]+-CBG$
+4
source

With a negative lookbehind, and knowing that all your lines end on a specific line:

.*(?<![9]{4}-CBG)$

Live demo

+1
source

All Articles