Regular Expressions or 'regexp' is a system used for pattern-matching in text strings. LivePerson's Rule Engine can use regexps to make writing and using Conditions easier.
For example, you might want to trash all emails where the subject contains the words dog, horse, or cat. Instead of writing three separate Conditions, you may use just one Regular Expression that checks for those three words.
Regexp offers a wide range of options. There is a test facility within the Condition area of Rules where you can try matching expressions to strings, as well as a list of the possible functions. This article outlines some of the basic operations, to enable you to get started with regexp.


A regular expression consists of zero or more branches, separated by the | vertical bar character. Any of the branches could be a possible match.
  • (dog|horse|cat) will match lines that contain any of these three branches.
A branch consists of zero or more pieces, concatenated. A match is attempted for the first piece, followed by a match for the second, etc.
  • (t[o|a]t[o|a]) will match lines that either contain the character 't' followed by either 'o' or 'a', then another 't' followed by 'o' or 'a'("toto", "tata", "tota" and/or "tato")
A piece is an atom, which may be followed by a repetition operator such as ?, + or *.
  • ? matches zero or one matches of the atom. (br[e]?d) will match lines containing "brd" and "bred"
  • + matches a sequence of one or more matches of the atom. (br[e]+d) will match lines containing "bred", "breed", "breeed", etc
  • * matches a sequence of zero or more matches of the atom. (br[e]*d) will match lines containing "brd", "bred", "breed", "breeed", etc
You can also look for a specific number of occurrences:
  • {n} The preceding item is matched exactly n times
  • {n,} The preceding item is matched n or more times
  • {n,m} The preceding item is matched at least n times, but not more than m times.
For example:
  • (M(iss){2}ippi) will match the string "Mississippi"
  • (M(iss){2,}ippi) will match the strings "Mississippi", "Missississippi", "Mississississippi", etc
  • (M(iss){2,3}ippi) will match the strings "Mississippi", "Missississippi"
An atom can be:( ) a regular expression in parentheses.[ ] a range, which is a sequence of characters. It usually matches any single character from the sequence. For example, [aeiou] will match any vowel. If two characters in the sequence are separated by -, the expression matches the full list of ASCII characters between them. For example, [a-z] will match any single lower case letter of the alphabet.
any single character.
A null string at the beginning of the input string. For example, ^(Once upon a time) will match lines beginning with "Once upon a time".
A null string at the end of the input string. For example, (The end)$ will match lines ending with "The end".
\c a special character, c, that is escaped by the backslash. This matches lines containing the special character c. This can also be done by enclosing the single special character in [ ].
a single character, where c is a character with no special meaning.
\sa space, tab or line break.
(^live person$) will match a line that only contains the string "live person"
([$]*[0-9]*[.][0-9][0-9][$]*) will match a line that contains a price either in the form $100.00 or 100.00$
([$]*[0-9]{1,}[.][0-9]{2}[$]*) will have the same result

Commonly Used Regular Expressions:

  • IP Addresses:To match an IP address from a list, use 123.321.214.125|654.254.154.369 (Addresses separated by | )

    Note: If the condition is meant to apply to fields that can be manually altered, such as a survey question, the period (.) might be matched as any single character. To avoid this result, place a backslash (\) before each period: 123\.321\.214\.125|654\.254\.154\.369

  • Free Text: Free text strings may be used for conditions pertaining to entries within a chat, answers to survey questions and much more. For instance, to look for the phrases "bad service/services" or "bad support" for chat tracking purposes, use bad\s(service(s)?|support)
  • Site Addresses (URL):To match page or directory on your site, you may simply use The LivePerson Rule Engine will automatically look for that phrase within any other phrase, such as or

    Quick Reference

    match any single character
    match zero or more of the previous items
    match one or more of the previous items
    match zero or one of the previous items
    remember contents of parenthesis as item
    match one item in this list
    create a range in a list
    match to the beginning of the field
    match to the end of the field
    escape any of the above

Keywords: regular expressions regexp pattern-matching reg