Skip to content

Filter with Regular Expressions

First: Using Wildcard

You might have already encountered vScope’s match filters, which enable searching using wildcards.

Example using Wildcards:

To display all servers with a program file name starting with “sql”, you can use a wildcard in the Filter Pane: Set Installed Applications to *sql*.

However, there are situations requiring more precise filtering. In these instances, you can leverage RegEx (Regular Expressions).

Regular Expressions

Regular Expressions can be thought of as a more sophisticated form of wildcards. While they have a steeper learning curve, they offer significantly greater power, allowing you to create search queries that are impossible with simple wildcards.

RegEx strings can be used in almost any vScope input field where filtering or searching is available. This includes the Filter Pane in Tables, when creating a Tracker case, or when using Free Text Search.

Example using RegEx

In this example, we aim to display all virtual hosts with virtual machines (VMs) running software with a name starting with “sql-” but exclude those where the name includes the word “express”. This type of query is useful for calculating Microsoft SQL license requirements. Achieving this level of filtering is challenging with standard wildcards, as it would necessitate two match filters, and vScope typically allows only one. Instead, use a RegEx like the one shown below:

  1. Create a Table displaying virtual hosts.
  2. Apply a filter on Guest Database Software with the value: regex:(?sui).*sql(?!.*express).*

The result will be a list of all VMware hosts running VMs with a version of SQL, excluding those identified as “Express” versions.

Let’s break down the RegEx used in this example:

  • regex: - This prefix tells vScope that the following string is a Regular Expression.
  • (?sui) - This part specifies case-insensitive matching.
  • .* - In RegEx, . matches any single character (except newline by default), and * matches the preceding element zero or more times. So, .* acts as a wildcard matching any sequence of characters.
  • sql - This literally matches the characters “sql”.
  • (?! ) - This is a “negative lookahead” assertion. It checks if a certain pattern does not exist immediately after the current position, without consuming any characters.
  • (?!.*express) - This specific negative lookahead ensures that any sequence of characters followed by “express” does not appear after “sql”.

Regular Expressions are a powerful and comprehensive language with extensive capabilities. Learn more about Regular Expressions, and you’ll unlock even more advanced filtering possibilities within vScope!