User Guide

Table Of Contents
Regular expression syntax 145
You use the following syntax to find repeating characters:
{m,n}
Where m is 0 or greater and n is greater than or equal to m. Match m through n (inclusive)
occurrences.
The expression {0,1} is equivalent to the special character ?.
{m,}
Where m is 0 or greater. Match at least m occurrences. The syntax
{,n} is not allowed.
The expression {1,} is equivalent to the special character +, and {0,} is equivalent to *.
{m}
Where m is 0 or greater. Match exactly m occurrences.
Case sensitivity in regular expressions
ColdFusion supplies case-sensitive and case-insensitive functions for working with regular
expressions.
REFind and REReplace perform case-sensitive matching and REFindNoCase and
REReplaceNoCase perform case-insensitive matching.
You can build a regular expression that models case-insensitive behavior, even when used with a
case-sensitive function. To make a regular expression case insensitive, substitute individual
characters with character sets. For example, the regular expression [Jj][Aa][Vv][Aa], when used
with the case-sensitive functions
REFind or REReplace, matches all of the following string
patterns:
JAVA
java
Java
jAva
All other combinations of case
Using subexpressions
Parentheses group parts of regular expressions together into grouped subexpressions that you can
treat as a single unit. For example, the regular expression "ha" specifies to match a single
occurrence of the string. The regular expression "(ha)+" matches one or more instances of “ha”.
In the following example, you use the regular expression "B(ha)+" to match the letter "B"
followed by one or more occurrences of the string "ha":
<cfset IndexOfOccurrence=REFind("B(ha)+", "hahaBhahahaha")>
<!--- The value of IndexOfOccurrence is 5 --->
You can use the special character | in a subexpression to create a logical "OR". You can use the
following regular expression to search for the word "jelly" or "jellies":
<cfset IndexOfOccurrence=REFind("jell(y|ies)", "I like peanut butter and
jelly">
<!--- The value of IndexOfOccurrence is 26--->