Name
REFindNoCase
Synopsis
REFindNoCase(regex, string
[,startpos
] [,returnsubexpressions
])
Performs a case-insensitive 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),
REFindNoCase( )
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
REFindNoCase( )
is unable to find a match for the
regular expression, 0 is returned. Here’s an example
that demonstrates the use of the REFindNoCase( )
function with the returnsubexpressions
parameter set to true
:
<cfset MyString="The name of the bank robber is Rob."> <cfset Matches= ReFindNoCase("(Rob)", MyString, 1, "true")> <cfoutput> <b>String:</b> #MyString#<br> <b>Regex:</b> RefindNoCase("catRob", MyString, 1, "true")<br> <b>Position:</b> #Matches.pos[1]#<br> <b>Length:</b> #Matches.len[1]# </cfoutput> <cfdump var="#Matches#">
Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.