User Guide

Table Of Contents
158 Chapter 7: Using Regular Expressions in Functions
Types of regular expression technologies
Many types of regular expression technologies are available to programmers. JavaScript, Perl, and
POSIX are all examples of different regular expression technologies. Each technology has its own
syntax specifications and is not necessarily compatible with other technologies.
ColdFusion supports regular expressions that are Perl compliant with a few exceptions:
A period, ., always matches newlines.
In replacement strings, use \n instead of $n for backreference variables. ColdFusion escapes all
$ in the replacement string.
You do not have to escape backslashes in replacement strings. ColdFusion escapes them, with
the exception of case conversion sequences or escaped versions (e.g. \u or \\u).
Embedded modifiers ( (?i), etc. ) always affect the entire expression, even if they are inside a
group.
\Q and the combinations \u\L and \l\U are not supported in replacement strings.
The following Perl statements are not supported:
Lookbehind (?<=) (<?!)
\x{hhhh}
\N
\p
\C
An excellent reference on regular expressions is Mastering Regular Expressions, by Jeffrey E. F.
Friedl, O'Reilly & Associates, Inc., 1997, ISBN: 1-56592-257-3, available at www.oreilly.com.
REFind ("[Uu]\.?[Ss]\.?[Aa}\.?", Report )
The position in the variable Report of the
first occurrence of the abbreviation USA.
The letters can be in either case and the
abbreviation can have a period after any
letter.
REFindNoCase("a+c","ABCAACCDD")
4
REReplace("There is is coffee in the the kitchen",
"([A-Za-z]+)[ ]+\1","*","ALL")
There * coffee in * kitchen
REReplace(report, "<[^>]*>", "", "All")
Removes all HTML tags from a string
value of the report variable.
Expression Returns