Skip Navigation
Regular expressions and how they apply to rules
Answer ID 486   |   Last Review Date 02/02/2022

What are regular expressions and how do they apply to rules?


Regular Expressions used in Business Rules


A regular expression uses operators and character strings to specify a set of character strings, which can be used when configuring rules to allow more flexibility in the criteria used to route or escalate records.

Note: When using regular expressions, an asterisk (*) does NOT represent a wildcard. Instead, the asterisk makes the preceding character optional. For more information on this, refer to Answer ID 861: Rules Matching Incorrectly.

It is important to understand that the ‘Regular Expression’ operator evaluates the raw data/text that is input into the database. Additionally, for incident threads, HTML Markup will be considered too.  

The table below provides some types of regular expressions that may be used with business rules. When working with regular expressions, the operator for the field you select must be either Matches Regular Expression or Does Not Match Regular Expression.

Pipe for OR conditions: The most common usage of regular expressions used with rules is the pipe ( | ). The pipe is used to specify a series of words or phrases that you are interested in matching. The pipe acts as an OR statement between each item separated by the pipe character. For example, to set up a criteria that matches the rule if the subject of an email contains "help" or "assistance", you can set up the criteria in the rule as listed below:

Incident.Summary matches regular expression help|assistance

You can then add additional criteria or specify actions to complete the configuration of your rule.

Case sensitivity:  Terms listed in regular expressions are not case sensitive, so if the rule is set to match the regular expression ABC, then the following expressions will match:  ABC, abc, abC, ABc.

The expression [A-Z] with the brackets is a specific regular expression to check for uppercase characters in the expression.

Testing rules: Once your rule is configured, be sure to test the rule by creating or editing test records to your site. Create or edit at least one record that will match the rule to verify that the rules you configure act on the record as you expect. Also create or edit at least one record that should not match your rules to verify that the rule will not affect records that they shouldn't.


The following table lists some of the regular expression operators that work with business rules. Oracle RightNow CX accepts any regular expression using POSIX Extended Syntax.

Descriptions of Regular Expressions

[ ]  -- Matches any character in the brackets.
[0-9]  -- Matches any number between 0 and 9.
[A-Za-z] -- Matches any character A-Z or a-z.
[^] -- Matches any characters NOT in the brackets. The first character in the brackets must be ^.
text1|text2 -- The pipe characters act as a Boolean OR, that is, text1 OR text 2 results in a match.
Note: Do not include a pipe at the beginning or end of your regular expression.
. -- Matches any single character except a new line
? -- The preceding item is optional and matched at most once.
* -- The preceding item is repeated as many times as necessary to match. Also matches if preceding item is not present.
+ -- The preceding item will be matched one or more times.
{n} -- The preceding item is matched exactly n times.
{n,} -- The preceding item is matched n or more times.
{,m}  -- The preceding item is optional and is matched at most m times.
{n,m} -- The preceding item is matched at least n times, but not more than m times.
\w -- Any alphanumeric character
( ) -- Used to group elements of the regular expression, as in arithmetic.
^ -- Match if at start of line
$ -- Match if at end of line
\  -- Quote or escape a character that would otherwise be interpreted as a syntactic character. Characters that must be quoted are: + ? | ( ) { }

Examples of Regular Expressions

This regular expression:   matches:
^ABC -- ABC at the beginning of a line
ABC$ -- ABC at the end of a line
^ABC$ -- ABC as the only word on the line
^...$ -- Any line with exactly three characters
^......-.....1  -- Any reference number ending in '1'
t.e -- tae, tbe, tce, t%e, tie, the, toe ....
at*e -- ae, ate, atte, attte, atttte ...
at+e -- ate, atte, attte ...
at?e -- ae, ate
m[aeiou]t -- mat, met, mit, mot, mut
cat|mat -- cat, mat
lo{4}ng -- loooong
lo{2,4}ng -- loong, looong, loooong
ward | ward\. | ^ward -- "ward" surrounded by spaces (this prevents "forward" or "backward" from matching), "ward" at the end of a sentence, and "ward" at the beginning of a line (no preceding space).