[Solved] Advanced config search terms

General discussion of anything Unimus
Post Reply
kingtrw
Posts: 48
Joined: Sun Dec 26, 2021 8:56 pm

Mon Apr 11, 2022 10:21 am

The config search feature is proving to be an absolute godsend in debugging a legacy network, I've already used it to reveal so many weird things.

I'm wondering if it's possible to combine search terms, for instance I'd like to see all devices that include "ip address dhcp" but do NOT include "ip routing"

My regex is extremely weak, so any help in crafting the syntax would be really appreciated.

Thanks!
User avatar
Tomas
Posts: 1206
Joined: Sat Jun 25, 2016 12:33 pm

Mon Apr 11, 2022 3:57 pm

Lookups like these (conditions like "something but not something else") are not idea in regex, but still possible. It is however order dependent.

For example, to find "ip address dhcp" where NOT followed by "ip routing", you can use this regex:

Code: Select all

(?s)ip address dhcp(?!.+ip routing)
Here is a link to show it in use. It's not matching right now, but remove "ip routing" and it will match:
https://regex101.com/r/81FDvb/1

The other case (find "ip address dhcp" where NOT preceded by "ip routing") is a bit more messy:

Code: Select all

(?s)^(?!.+ip routing).+?ip address dhcp
Here is an example. Same as before, remove "ip routing" and it will match:
https://regex101.com/r/6fdev1/1
Post Reply