The Match Regular Expression function utilizes special characters to create regular expressions (also called regex) to describe a search pattern. In the Match Regular Expression Function
, the regular expression input defines your search string for the given input string.
If your search string contains special characters used by regular expressions
(regardless of display format), your function will return values based on the regular expressions search parameters. For example, if you are using the regular expression string "abc." to find a match in the input string "abcdefg" the returned values will be:
- before substring: null
- match substring: abcd
- after substring: efg
- offset past match: 4
The reason the match string returns "abcd" and not null
is due to the special character of "." being included in the regular expression. The "." special character is interpreted as a wildcard in regular expressions and will return almost any value that it see (in this case the character "d" in the input string).
To avoid a special character from being interpreted as a regular expression, you can place the "\" character before the special character to "escape" its function. For example, if you are using the regular expression string "abc\." to find a match in the input string "abcdefg" the returned values will be:
- before substring: abcdefg
- match substring: null
- after substring: null
- offset past match: -1
which is correctly interpreting the regular expression as not being a match to the input string.