MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual page 156

Developing coldfusion mx applications
Table of Contents

Advertisement

The following figure shows the output of the
If you include subexpressions in your regular expression, each element of
element one contains the position and length of the first occurrence of each subexpression in the
search string.
In the following example, the expression [A-Za-z]+ is a subexpression of a regular expression. The
first match for the expression ([A-Za-z]+)[ ]+, is "is is".
<cfset sLenPos=REFind("([A-Za-z]+)[ ]+\1",
"There is is a cat in in the kitchen", 1, "True")>
<cfoutput>
<cfdump var="#sLenPos#">
</cfoutput><br>
The following figure shows the output of the
The entries sLenPos.pos[1] and sLenPos.len[1] contain information about the match of the entire
regular expression. The array elements sLenPos.pos[2] and sLenPos.len[2] contain information
about the first subexpression ("is"). Because
expression match only, the
match to the regular expression, "in in".
The regular expression in the following example uses two subexpressions. Therefore, each array in
the output structure contains the position and length of the first match of the entire regular
expression, the first match of the first subexpression, and the first match of the second
subexpression.
<cfset sString = "apples and pears, apples and pears, apples and pears">
<cfset regex = "(apples) and (pears)">
<cfset sLenPos = REFind(regex, sString, 1, "True")>
<cfoutput>
<cfdump var="#sLenPos#">
</cfoutput><br><br>
156
Chapter 7: Using Regular Expressions in Functions
cfdump
cfdump
REFind
structure does not contain information about the second
sLenPos
tag:
pos
tag:
returns information on the first regular
and
after
len

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents