Case Sensitivity In Regular Expressions; Using Subexpressions; Using Special Characters - MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual

Developing coldfusion mx applications
Table of Contents

Advertisement

m
{
,}
Where m is 0 or greater. Match at least m occurrences. The syntax
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
REReplaceNoCase
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
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--->

Using special characters

Regular expressions define the following list of special characters:
+ * ? . [ ^ $ ( ) { | \
In some cases, you use a special character as a literal character. For example, if you want to search
for the plus sign in a string, you have to escape the plus sign by preceding it with a backslash:
"\+"
and
perform case-sensitive matching and
REReplace
perform case-insensitive matching.
or
REFind
, matches all of the following string
REReplace
n
is not allowed.
{,
}
REFindNoCase
Regular expression syntax
and
147

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Coldfusion mx

Table of Contents