Skip to Main Content
Programming ColdFusion MX, 2nd Edition
book

Programming ColdFusion MX, 2nd Edition

by Rob Brooks-Bilson
August 2003
Intermediate to advanced content levelIntermediate to advanced
1140 pages
68h 45m
English
O'Reilly Media, Inc.
Content preview from Programming ColdFusion MX, 2nd Edition

Name

REFind

Synopsis

                  
                  
                  REFind(regex, string [, startpos] [, returnsubexpressions])

Performs a case-sensitive search. 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 arrays, pos and len that represents the position and length, respectively, of the matched regular expression. If the regular expression contains parenthesized subexpressions, the first index of the array returns the len and pos of the first occurrence of the match for the entire regular expression. Each subsequent array index in the returned structure contains the len and pos for the first occurrence of each parenthesized subexpression in 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 ratio of good to bad apples is 4:1."> <cfset matches= REFind("([0-9]+):([0-9]+)", MyString, 1, "true")> <cfoutput> <b>String:</b> #MyString#<br> <b>Regex:</b> REFind(&quot;([0-9]+):([0-9]+)&quot;, MyString, 1, &quot;true&quot;)<br> <b>Position:</b> #matches.pos[1]#<br> <b>Length:</b> #matches.len[1]# </cfoutput> <p> Dump: <cfdump var="#matches#"> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming ColdFusion

Programming ColdFusion

Rob Brooks-Bilson

Publisher Resources

ISBN: 0596003803Supplemental ContentErrata Page