Pattern Exclusion
- Last Updated: December 11, 2024
- 1 minute read
- WhatsUp Gold
- Version 2024
The Configuration Management regular expression (regex) engine supports both pattern matching and pattern exclusion.
Pattern exclusion is applied using a mechanism referred to as negative look-ahead. It takes this syntax:
(?!(
myvalue
))
—Where "?!" is the negative lookahead operator.
Return Records Containing String A but not B
Let's say you want to validate changes to your subnet mask across your enterprise 255.255.0.0, but you suspect that some of your routers might have the wrong value for the second octet. Ensure the Regex checkbox is checked.
Syntax
.*255\.(?!(255)).*
Regex Syntax Details
This section explains the syntax used for the preceding example.
- "
.*" matches 0 or more of any character (such as tabs, whitespace characters, keywords) - The literal string "
255" matches the first octet of the submask. - "
\." (escaped dot character) matches the octet separator literal. (?!(255))excludes matches with the literal string "255" for indicating the second octet in the subnet.