Understanding "Matches Pattern" and Regular Expressions in LeadConduit

LeadConduit rules that operate on text include a "matches pattern" option. You enter that pattern into the rule in the form of a "regular expression".


Also, some LeadConduit response-parsing mappings can be defined using regular expressions.


What is a regular expression?

So, what is a regular expression ("regex")?

A regular expression is a type of shorthand that describes to the regex engine how to find matching character combinations in a string. Where regular expressions are used in an application there is a regular expression "engine" hidden in the background, waiting to be fed a regular expression pattern and a subject string to search.

Think of the engine as a mini-program that analyzes the subject string using the regex pattern as its instructions and returns "true" if it finds a match or "false" if it does not.

In some situations, the engine may "capture" and return a pattern-defined portion of the subject string.

(In some applications the regex engine can even make substitutions to re-write the subject string, but substitution/rewrite is not applicable in LeadConduit.)

Other Resources: Learning Regular Expression Syntax

Volumes have been written about regular expressions. Teaching it is beyond the scope of this knowledge base. Here, though, are some excellent online resources.

One last thing...

There is one "gotcha" that every beginner using regular expressions experiences, so we WILL teach you about that.

There are 12 characters with special meanings to the regex engine:

  • the backslash \
  • the caret ^
  • the dollar sign $
  • the period or dot .
  • the vertical bar or pipe symbol |
  • the question mark ?
  • the asterisk or star *
  • the plus sign +
  • the opening parenthesis (
  • the closing parenthesis )
  • the opening square bracket [
  • and the opening curly brace {

These special characters are often called "metacharacters". If you want to use any of these characters as a literal in a regex, you need to escape them by preceding them with a backslash.

For example,

If you want to match the string $1.98 the correct pattern is /\$1\.98/
If you want to match the string the correct pattern is /tom\.jones@test\.com/
If you want to match the string foo[bar] the correct pattern is /foo\[bar]/
If you want to match the string foo(bar) the correct pattern is /foo\(bar\)/

Regular expressions are powerful tools, but they can be tricky. Always test your regular expressions before going live.

Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request


You must be logged in to comment.