492
CFML Language Reference
length of the first instance of each subexpression within the regular expression are
returned in subsequent elements of the arrays.
Examples
<!--- This example shows the use of REFind --->
<HTML>
<HEAD>
<TITLE>
REFind Example
</TITLE>
</HEAD>
<BODY>
<H3>REFind Example</H3>
<P>This example demonstrates the use of the REFind function with and
without the <i>returnsubexpressions</i> parameter set to True.</P>
If you do not use the <i>returnsubexpressions</i> parameter, REFind
returns the position of the first occurrence of a regular expression in a
string starting from the specified position. Returns 0 if no occurrences
are found.
</P>
<P>REFind("a+c+", "abcaaccdd"):
<CFOUTPUT>#REFind("a+c+", "abcaaccdd")#</CFOUTPUT></P>
<P>REFind("a+c*", "abcaaccdd"):
<CFOUTPUT>#REFind("a+c*", "abcaaccdd")#</CFOUTPUT></P>
<P>REFind("[[:upper:]]", "abcaacCDD"):
<CFOUTPUT>#REFind("[[:upper:]]", "abcaacCDD")#</CFOUTPUT></P>
<P>REFind("[\?&]rep=", "report.cfm?rep=1234&u=5"):
<CFOUTPUT>#REFind("[\?&]rep=", "report.cfm?rep=1234&u=5")#</CFOUTPUT>
</P>
<!--- Set startPos to one; returnMatchedSubexpressions = TRUE --->
<hr size="2" color="#0000A0">
<P>If you do use the <i>returnssubexpression</i> parameter, REFind
returns the position and length of the first occurrence of a regular
expression in a string starting from the specified position. The position
and length variables are stored in a structure. In order to access
the position and length information, you must use the keys <i>pos</i> and
<i>len</i>, respectively.</P>
<CFSET teststring ="The cat in the hat hat came back!">
<P>The string in which the function is to search is:
<CFOUTPUT><b>#teststring#</b></CFOUTPUT>.</P>
<P>The first call to REFind to search this string is: <b>REFind("[A-Za-
z]+",testString,1,"TRUE")</b></P>
<P>This function returns a structure that contains two arrays: pos and
len.</P>
Summary of Contents for COLDFUSION 4.5-CFML LANGUAGE
Page 1: ...Allaire Corporation CFML Language Reference ColdFusion 4 5...
Page 207: ...Chapter 1 ColdFusion Tags 183 CFCATCH CFTRY BODY HTML...
Page 224: ...200 CFMLLanguageReference CFOUTPUT P Text within CFOUTPUT is always shown CFOUTPUT BODY HTML...
Page 336: ...312 CFMLLanguageReference CFIF BODY HTML...
Page 404: ...380 CFMLLanguageReference DE It is morning CFOUTPUT P BODY HTML...
Page 413: ...Chapter 2 ColdFusion Functions 389 Customer BalanceDue BR CFOUTPUT CFIF BODY HTML...
Page 483: ...Chapter 2 ColdFusion Functions 459 CFOUTPUT CFLOOP BODY HTML...
Page 584: ...560 CFMLLanguageReference...
Page 594: ...570 CFMLLanguageReference...