Regular Expression Operators

Regular expression queries in the Work Center search support the regexp and query_string queries. The Work Center search regular expression engine does not allow all types of regular expression operators.

Supported Operators

This section describes the supported operators.

Anchors

In Work Center, a regex search is automatically wrapped with the ^ or $ anchors to address full-word content. During a search, the regex is applied to each word in an item's text fields. If at least one word an item corresponds to the given regex, that item is returned in the search results. This means you do not need to use ^ or $ before or after your string.

For example, to find the string "DEF1234" you can use:

DEF123.+

This returns a match for "DEF1234". However, this does not:

DEF123

Reserved Characters

You can use any Unicode character in your query, except for the following reserved characters, which must be escaped:

. ? + * | { } [ ] ( ) " \
Note that when using the optional operators listed below, the following characters are also reserved:
# & < >  ~

To escape a reserved character, use a backslash "\*". To escape a backslash, use "\\".

Characters that are surrounded by double quotes are treated literally (except for double quotes themselves):
\~smile:-\)
“~smile:-)”

Match One or More Times

Use the plus symbol "+" to match the preceding element one or more times. The following matches string "DMPROD_EEC_22239":

DMPROD_E+C_2+39

Match any Character

Use a period "." in place of any character. The following matches string "DMPROD_EEC_22239":

DMPROD_EEC_2..39
.+_EEC_.+

Match Zero or More

Use an asterisk "*" to match the preceding element zero or more times. The following matches string "DMPROD_EEC_22239":

DMPROD_EE*C_2*39

Match Zero or One

Use a question mark "?" to match the preceding element zero or one time (in other words, make it optional). The following matches string "DMPROD_EEC_22239":

DMPROD_EE?C_2222?39

However, this does not:

DMPROD_E?C_22?39

Match Between n and m Times

Use curly brackets {} to match the preceding element at least n times, but no more than m times, where n and m are integers. For example:

  • {3} – Repeat exactly three times.
  • {2,4} – Repeat at least twice, but no more than four times.
  • {3,} – Repeat at least three times.

The following match string "DMPROD_EEC_22239":

DMPROD_E{2}C_2{3}39
DMPROD_E{1,2}C_2{2,4}39
DMPROD_E{2,}C_2{3,}39

However, this does not:

DMPROD_E{3}C_2{4,}39

Grouping

Use parentheses "()" to form sub-expressions. Use the quantity operators above to operate on the shortest previous element as a group.

The following match string "DMPROD_EEC_22239":

DMPROD(_EEC)+_22239
.+(_EEC){1,}.+

However, this does not:

(_EEC){1,}

Alternation

Use the pipe symbol "|" as an OR operator. This means a match is found if either the left side of the pipe symbol is found or if the right side of the pipe symbol is found. The alternation applies to the longest patter, not the shortest.

The following match string "DMPROD_EEC_22239":

DMPROD_EEC.+|DMDEV_EEC.+ 
DMPROD(_EEC|_ABC).+

However, this does not:

.+_12345|.+_54321

Character Classes

To match a string that contains a range of characters (e.g. "DEF-12345):

Use square brackets [] to indicate a range of characters:

[DEF]+-12345

Use a dash - to specify a range of characters within square brackets.

[D-F]+-12345

The dash is literal if it is used as the first character or if it is properly escaped \-:

[-EFD]+12345
[EDF\-]+12345
Note: A dash - is treated as a regular symbol if it is outside square brackets or if it the first character inside the brackets. To use a dash as a regular symbol inside square brackets, it must be escaped.

Use a leading carat ^ to specify characters that must not appear for a match to occur:

[^INT]+-12345

However, these do not match:

[DEF-]+12345
[^A-Z]+-12345

Optional Operators

Available optional operators are listed below.

Complement

Use the tilde symbol "~" to negate the shortest pattern that follows it. For example, when using an expression like "xy~z1":

  • The match starts with x
  • Followed by y
  • Followed by a string of any length that is not z
  • And ends with 1

The following match string "DMPROD_EEC_22239":

DMPROD_~A9
DMPROD_~(ABC)_22239

However, this does not:

DMPROD_~(EEC)_22239

Interval

Use angle brackets "<>" to indicate a numeric range.

The following match string "DMPROD_EEC_22239":

DMPROD_EEC_<1-30000>
DMPROD_EEC_<01-30000>

However, this does not:

DMPROD_EEC_<1-3>

Intersection

Use an ampersand "&" to require that both patterns have to match.

The following matches string "DMPROD_EEC_22239":

DMPROD.+&.+22239

However, this does not:

DMPROD&22239

Consider re-writing your regular expression if you are using the intersection option.