Skip to main content
Skip table of contents

Examples - excluding a string

Using Regex for specific filter: Exclude a string

In this example we want to exclude everything that contains the string server.

To do this, we will use the following Regular Expression:

^((?!.*server.*).)*$

Breakdown of Regex elements used

^Beginning of the string
()Capturing Group
(?!)Negative look ahead. Specifies a group that cannot match after the main expression.
(i.e. if it matches, then the result is discarded)
.Matches any character except line breaks
*Match 0 or more of the preceding token
serverString
$End of the string
Note

You can get the same result by excluding each character of the string.

^((?![s][e][r][v][e][r]).)*$

^Beginning of the string
()Capturing Group
(?!)Negative look ahead. Specifies a group that cannot match after the main expression.
(i.e. if it matches, then the result is discarded)
[]Matches any character in the set
sCharacter
eCharacter
rCharacter
vCharacter
eCharacter
rCharacter
.Matches any character except line breaks
*Match 0 or more of the preceding token
$End of the string

Practical case

In this example we will use Filter by Regular Expression to exclude everything that contains the string server in the Type column.

regex-examples-8


Click on the filter icon 
regex-Filt-Button
regex-Filt-Button
 and select Filter By Regular Expression.

filter-by-regular-expression


regular-expression-to-be-used


Having used the expression ^((?!.*server.*).)*$ to filter the column, all lines that contained the string server have now been excluded.

regex-examples-11


TIP

Excluding multiple strings:

If you need to exclude two or more strings, like server and person, you can use the following Regex:

^((?!.*(server|person).*).)*$

^Beginning of the string
()Capturing Group
(?!)Negative look ahead. Specifies a group that cannot match after the main expression.
(i.e. if it matches, then the result is discarded)
.Matches any character except line breaks
*Match 0 or more of the preceding token
serverString
|Match either the expression before or after
personString
$End of the string


Using the following Regex gives the same result.

^((?!.*server.*)(?!.*person.*).)*$

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.