August 2001
Intermediate to advanced
976 pages
38h 8m
English
REFind
REFind(regex, string[,startpos] [,returnsubexpressions])
Returns the position of the first occurrence of
regex in
string. regex
can be any valid ColdFusion regular expression. An optional starting
position for the search can be specified by
startpos. If
returnsubexpressions is set to
True (False is the default),
REFind( ) returns a CFML structure containing two
keys, pos and len, that
represents the position and length, respectively, of the matched
regular expression. If REFind( ) is unable to find
a match for the regular expression, 0 is returned. REFind( ) performs a case-sensitive search. The following example
demonstrates the use of the REFind( ) function
with the returnsubexpressions parameter
set to True:
<CFSET MyString="The name of the bank robber is Rob.">
<CFSET matches= ReFind("Rob", MyString, 1, "TRUE")>
<CFOUTPUT>
<B>String:</B> #MyString#<BR>
<B>Regex:</B> Refind("cat", MyString, 1, "TRUE")<BR>
<B>Position:</B> #matches.pos[1]#<BR>
<B>Length:</B> #matches.len[1]#
</CFOUTPUT>Read now
Unlock full access