Regular expressions
Regular expressions are an advanced syntax that allow you to search for a pattern of characters. For example, you can use regular expressions to locate Social Security numbers, credit card numbers, or other text that has a consistent pattern of characters.
To use a regular expression, you must enclose the regular expression in quotation marks and start the expression with ##. For example: "##[abc]"
The following table describes the regular expressions that you can use in search boxes.
Regular expression |
Description |
Example query and results |
\d |
Represents one number in the pattern. |
A search for "##\d" finds 1 and 2. |
\w |
Represents one alphanumeric character or underscore in the pattern. |
A search for "##\w" finds a and 1. |
* |
Indicates zero or more numbers, alphanumeric characters, or underscores in the pattern. |
A search for "##click\w*" finds click, clicked, and clicking. |
+ |
Indicates one or more numbers, alphanumeric characters, or underscores in the pattern. |
A search for "##click\w+" finds clicked and clicking, but not click. |
. (period) |
Represents any alphanumeric character or symbol. |
A search for "##appl." finds apple and appl2. |
[abc] [123] |
Indicates a set of characters, one of which must be present. The order of the characters does not matter. |
A search for "##d[uo]g" finds dug and dog, but not dig. |
[a-z] [0-9] |
Indicates a range of characters. |
A search for "##[a-z]" matches any lowercase character. A search for "##ma[a-e]e" finds made, but not make. |
[^abc] [^123] [^a-z] [^0-9] |
Indicates any character except the characters in the set or range. |
A search for "##c[^u]t" finds cat, but not cut. |
(abc|xyz) |
Indicates that either group of characters appears. |
A search for "##require(d|ment)" finds required and requirement. |
? |
Indicates that the preceding character appears zero or one times. Enclose the preceding character in parentheses. |
A search for "##colo(u)?r" finds color and colour. |
{n} |
Indicates that the preceding expression occurs exactly n times. |
To search for a pattern such as ABC1234, which consists of three letters followed by four digits, search for "##[a-z]{3}[0-9]{4}". To search for a pattern such as 123-45-6789, which consists of three digits, a hyphen, two digits, a hyphen, and four digits, search for "##\d{3}-\d(2)-\d{4}". To search for multiple characters in a character set, use the [abc] expression followed by the {n} expression. For example, a search for "##the[resm]{2}" finds words that start with the and contain two of the characters in the set [resm], such as there and these, but not words with one character in the set, such as them, or words with three characters in the set, such as themes. |
{n,} |
Indicates that the preceding expression occurs a minimum of n times. |
To search for a pattern that consists of the letters ABC followed by at least three digits, search for "##abc[0-9]{3,}". This search finds ABC123, ABC1234, ABC12345, and so on. |
{n,m} |
Indicates that the preceding expression occurs a minimum of n times, and a maximum of m times. To search for multiple characters in a character set, use the [abc] expression followed by the {n,m} expression. |
To search for numbers that are at least one digit and at most three digits, search for "##\d{1,3}". This search finds 8, 12, and 374, but not 2001. A search for "##the[mres]{1,2"} finds words that start with the and contain one or two characters in the set [mres], such as them and there, but not words with three characters in the set, such as themes. |
Regular expression examples
When creating the syntax for regular expressions, keep the following in mind:
To use a regular expression, you must enclose the regular expression in straight double quotation marks and start the expression with ##. For example: "##[abc]".
Do not use curly quotation marks.
To ensure that the syntax works as intended, your administrator must configure and index all characters and symbols in the syntax as letters, including the symbols in the Index as letter column in the following table.
If you are an administrator, see the following section after the table in this topic: For administrators: Configure characters and symbols in the index as letters.
Use all lowercase letters in your syntax. By default, the application configures the index to be case insensitive unless an administrator changes the indexing options to case sensitive.
Spaces are not searchable characters.
The following table provides examples of search types, the syntax to use, and sample results.
Search type |
Syntax |
Index as letter (administrator) |
Sample results |
United States Social Security Number (SSN) with hyphens |
"##((?!000)(?!666)([0-8]\d{2}))\-((?!00)\d{2})\-((?!0000)\d{4})" |
- (Hyphen; ASCII Code 45) |
777-77-7777 |
SSN without spaces |
"##\d{9}" |
|
777777777 |
SSN with spaces |
"##\d{3}" "##\d{2}" "##\d{4}" |
|
777 77 7777 |
Document ID |
"##doc\d{8}" |
|
Doc00000001 or DOC00000001 |
|
"##([\w_\.]+)@([\w_\.]+)\.([\w_\.]{2,6})" |
@ (At symbol; ASCII Code 64) . (Period symbol; ASCII Code 46) |
jdoe@domain.com jane.doe@domain.com johnsmith@document.gov.edu |
Date |
"##[0-9]{1,2}/[0-9]{1,2}/[0-9]{2,4}" |
/ (Forward slash; ASCII Code 47)
|
08/28/1963 8/28/1963 08/28/63 28/08/1963 |
Phone number (United States format) |
"##([0-9]{3}-)?[0-9]{3}-[0-9]{4}" |
- (Hyphen; ASCII Code 45) |
867-5309 800-649-2568 |
Visa |
"##4\d{12,15}" |
|
4321069823745 4321069823745123 |
Mastercard |
"##5[1-5]\d{14}" |
|
5490876543456782 5290876543456781 |
Discover |
"##6011\d{12}" OR "##65\d{14}" |
|
6011987623543109 6589043928435612 |
American Express |
"##3[4,7]\d{13}" |
|
340928374625172 371928172040238 |