Regex How to Include and Exclude in same expression
search cancel

Regex How to Include and Exclude in same expression

book

Article ID: 34711

calendar_today

Updated On:

Products

DX Unified Infrastructure Management (Nimsoft / UIM) CA Unified Infrastructure Management On-Premise (Nimsoft / UIM) CA Unified Infrastructure Management SaaS (Nimsoft / UIM)

Issue/Introduction

Regex How to Include and Exclude in same expression.

Environment

  • Release: Any

Resolution

Select all hosts that have <abc> but should not have <nim> in them.

This can be required in Distribution manager, nas alarm filters etc. You can use the following regex to include certain characters in a name while excluding those that have certain characters you don't want to include.

Examples to include:

abchyd
zyabc2
zyabc

Examples to exclude:

zyabcnimbu
zynimabcbu


If you want to get the ones which have "abc" but not "nim" in them, use the following regex:

/^(?!.*nim).*abc.*/