Skip Navigation
Expand
Regular Expressions are matched incorrectly
Answer ID 861   |   Last Review Date 11/16/2020

Why is the wrong business rule getting applied to an incident?

Environment:

Business Rules

Issue:

I have workflow rules and escalation rules configured for our site. When I check the rule log, I realize that the wrong rule was applied. Why is this happening?

Resolution:

When you have configured workflow and escalation rules using regular expressions, it sometimes appears that an incorrect rule was applied to a record when the underlying cause is that the regular expression is not set up correctly. To determine why the record matched a rule, carefully review the regular expression involved.

You can use the Rule Log to determine which rules matched and acted on your incidents. For more information on using the Rule Log, refer to Answer ID 1873: Using the Rule Log to Troubleshoot Rules.

 

Incorrect Use of Asterisks (*)

It is a somewhat common error when configuring regular expressions to use the asterisk (*) as a wildcard in the regular expression (as you might if you were to search on a word or part of a word). This is an incorrect configuration for regular expressions.

With regular expressions, the asterisk (*) means that the preceding character is matched zero or more times, which basically means that the preceding character becomes optional. For this reason, the incident may indeed match a rule that is configured with an asterisk for a regular expression.

For example, if you create a rule to match the regular expression, hat* in the Summary field, you are basically saying that the rule should match if any word in the Summary contains the character sequence "ha" (since the letter "t" is optional due to the *). All of the examples listed below would match:

  • Do you like my new hats?
  • Do you like my new haircut?
  • What do you like to eat?
  • Are my chances good?


If a rule acts on an incident in an unexpected manner, check that the regular expression defined in the rule is expressing your intent correctly. If you have used the asterisk (*) as a wildcard, remove it from the regular expression and save the rule and reactivate rulebase.

 

Text String Matches Longer Word

When words are entered in a regular expression, you are defining a text string that is matched, not a specific word. That is, regular expressions match the text string you define, regardless if the string is within a longer word or is a word itself.  NOTE: The 'Regular Expression' operator evaluates the raw data/text that is input into the database.

For example, you can define a regular expression that includes "fresh" as an element without spaces before or after the word, such as:

word1|fresh|word2

This expression would match the word "refreshment" as well as the specific word you indicated (fresh). This is because the word "fresh" is contained within the longer word. Therefore, incidents may match a rule if the incident contains a longer version of a word that incorporates one of the text strings defined in the regular expression.

Review your expression carefully along with the content of your record to determine if that text string is included within the record.

 

To include a specific word of interest in your expressions, you can include three components in the IF statement for the customer thread:

...| fresh | fresh\.|^fresh |...

The first component handles cases where the word "fresh" exists in a sentence and is surrounded by spaces. The second addresses "fresh" at the end of a sentence where the word is preceded by a space and followed by a period and the third option addresses the word at the beginning of a line.

Note: You may need to add additional components to address specific punctuation or cases how the word is used within the customer thread of an incident.

Similarly, if the IF statement involves the incident subject, you could use additional components to address the word at the beginning or end of the line:

...| fresh | fresh$|^fresh |...

In this situation, the first component still addresses the word itself surrounded by spaces. The second component indicates that the word is at the end of a line and the third component is for words at the beginning of the line.

 

For more information on using regular expressions, refer to Answer ID 486: Using Regular Expressions and Answer ID 2851: Regular expression is part of another word.

Available Languages for this Answer:

Notify Me
The page will refresh upon submission. Any pending input will be lost.