Using Regex with Smart Groups and Advanced Searches

This article explains how to configure search criteria based on a regular expression (regex) when using smart groups and advanced searches for mobile devices or computers in Jamf Pro.

Regex is a type of search pattern that uses special characters to help you find information. You can use regex to search for certain characters or patterns, words or phrases, or other complex information in Jamf Pro.

Requirements
  • Mobile Devices: Jamf Pro 10.3.0 or later

  • Computers: Jamf Pro 10.7.0 or later

  1. Log in to Jamf Pro.
  2. Create a smart group or an advanced search for computers or mobile devices.
  3. Select matches regex or does not match regex as the operator when creating your search criteria.

Common Regex Patterns

The following table lists some of the common regex patterns:

Regex Patterns

Description

. Matches any character, excluding new lines
^Matches the beginning of a line
?Matches 0 or 1 occurrences of a value
+Matches 1 or more times
*Matches 0 or more times
$Matches the end of a line
\dMatches a numeric digit

There are many additional regex patterns that can be used to search for information in Jamf Pro, and you are not limited to the ones listed here.

Note:

The > & < characters are XML reserved characters that overlap with valid regex characters. These reserved characters must be referenced as entities when the literal character is needed.

Regex Examples and Search Logic

Example 1

ObjectiveExample ValuesSearch CriteriaValues Returned
Find all buildings that end with a number

Building
Building 1
Building 2
Building 3
Building A

Criteria: Building
Operator: matches regex
Value: ^.+?\d$

Building 1
Building 2
Building 3

Example 2

ObjectiveExample ValuesSearch CriteriaValues Returned
Find all devices in all labs, excluding faculty machines

LAB-ART-101
LAB-CS-101
LAB-CS-102
Professor Smith's iPad
Professor Johnson's iPad

Criteria: Display Name
Operator: matches regex
Value: ^LAB-.*$

LAB-ART-101
LAB-CS-101
LAB-CS-102

Example 3

ObjectiveExample ValuesSearch CriteriaValues Returned
Find all devices that do not start with the word "Professor"

Professor Smith's iPad
Professor Johnson's iPad
iPad - Professor Jones
iPhone for Professor Davis

Criteria: Display Name
Operator: does not match regex
Value: ^Professor

iPad - Professor Jones
iPhone for Professor Davis