For the complete experience, please enable JavaScript in your browser. Thank you!

  • Creative Cloud
  • Photoshop
  • Illustrator
  • InDesign
  • Premiere Pro
  • After Effects
  • Lightroom
  • See all
  • See plans for: businesses photographers students
  • Document Cloud
  • Acrobat DC
  • eSign
  • Stock
  • Elements
  • Marketing Cloud
  • Analytics
  • Audience Manager
  • Campaign
  • Experience Manager
  • Media Optimizer
  • Target
  • See all
  • Acrobat Reader DC
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player
  • All products
  • Creative Cloud
  • Individuals
  • Photographers
  • Students and Teachers
  • Business
  • Schools and Universities
  • Marketing Cloud
  • Document Cloud
  • Stock
  • Elements
  • All products
  • Get Support
    Find answers quickly. Contact us if you need to.
    Start now >
  • Learn the apps
    Get started or learn new ways to work.
    Learn now >
  • Ask the community
    Post questions and get answers from experts.
    Start now >
    • About Us
    • Careers At Adobe
    • Investor Relations
    • Privacy  |  Security
    • Corporate Responsibility
    • Customer Showcase
    • Events
    • Contact Us
News
    • 3/22/2016
      Adobe Summit 2016: Are You An Experience Business?
    • 3/22/2016
      Adobe Announces Cross-Device Co-op to Enable People-Based Marketing
    • 3/22/2016
      Adobe and comScore Advance Digital TV and Ad Measurement
    • 3/22/2016
      Adobe Marketing Cloud Redefines TV Experience
CFML Reference / 

REFindNoCase

Adobe Community Help


Applies to

  • ColdFusion

Contact support

 
By clicking Submit, you accept the Adobe Terms of Use.
 

Description

Uses a regular expression (RE) to search a string for a pattern, starting from a specified position. The search is case-insensitive. For more information on regular expressions, including escape sequences, anchors, and modifiers, see Using Regular Expressions in Functions in the Developing ColdFusion Applications.

Returns

Depends on the value of the returnsubexpressions__parameter:

  • If returnsubexpressions__= "False":
    • The position in the string where the match begins
    • 0, if the regular expression is not matched in the string
  • If returnsubexpressions = "True": a structure that contains two arrays, len and pos. The array elements are as follows:
    • If the regular expression is found in the string, the first element of the len and pos arrays contains the length and position, respectively, of the first match of the entire regular expression.
    • If the regular expression contains parentheses that group subexpressions, each subsequent array element contains the length and position, respectively, of the first occurrence of each group.
    • If the regular expression is not found in the string, the first element of the len and pos arrays contains 0.

Category

String functions

Function syntax

REFindNoCase(reg_expression, string [, start, returnsubexpressions])

See also

Find, FindNoCase, REFind, REReplace, REReplaceNoCase

Parameters

Parameter

Description

reg_expression

Regular expression for which to search. Case-insensitive.For more information, see Using Regular Expressions in Functions in the Developing ColdFusion Applications.

string

A string or a variable that contains one. String in which to search.

start

Optional. A positive integer or a variable that contains one. Position at which to start search. The default value is 1.

returnsubexpressions

Optional. Boolean. Whether to return substrings of reg_expression, in arrays named len and pos:

  • True: if the regular expression is found, the first array element contains the length and position, respectively, of the first match. If the regular expression contains parentheses that group subexpressions, each subsequent array element contains the length and position, respectively, of the first occurrence of each group. If the regular expression is not found, the arrays each contain one element with the value 0.
  • False: the function returns the position in the string where the match begins. Default.

Usage

This function finds the first occurrence of a regular expression in a string. To find the second and subsequent instances of the expression or of subexpressions in it, you call this function more than once, each time with a different start position. To determine the next start position, use the returnsubexpressions__parameter, and add the value returned in the first element of the length array to the value in the first element of the position array.

Example

<h3>REFindNoCase Example</h3> 
<p>This example demonstrates the use of the REFindNoCase function with and 
without the <i>returnsubexpressions</i> parameter set to True.</p> 
<p>If you do not use the <i>returnsubexpressions</i> parameter, REFindNoCase 
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>REFindNoCase("a+c+", "abcaaccdd"): 
<cfoutput>#REFindNoCase("a+c+", "abcaaccdd")#</cfoutput></p> 
<p>REFindNoCase("a+c*", "abcaaccdd"): 
<cfoutput>#REFindNoCase("a+c*", "abcaaccdd")#</cfoutput></p> 
<p>REFindNoCase("[[:alpha:]]+", "abcaacCDD"): 
<cfoutput>#REFindNoCase("[[:alpha:]]+", "abcaacCDD")#</cfoutput></p> 
<p>REFindNoCase("[\?&]rep = ", "report.cfm?rep = 1234&u = 5"): 
<cfoutput>#REFindNoCase("[\?&]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, REFindNoCase 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. To access position and length 
information, 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 REFindNoCase to search this string is: 
<b>REFindNoCase("[[:alpha:]]+",testString,1,"True")</b></p> 
<p>This function returns a structure that contains two arrays: pos and len.</p> 
<p>To create this structure you can use a CFSET statement, 
for example:</p> 
&lt;CFSET st = REFindNoCase("[[:alpha:]]+",testString,1,"True")&gt; 
<cfset st = REFindNoCase("[[:alpha:]]+",testString,1,"True")> 
<p> 
<cfoutput> 
The number of elements in each array: #ArrayLen(st.pos)#. 
</cfoutput></p> 
<p><b>The number of elements in the pos and len arrays will always be one, 
if you do not use parentheses to denote subexpressions in the regular 
expression.</b></p> 
<p>The value of st.pos[1] is: <cfoutput>#st.pos[1]#.</cfoutput></p> 
<p>The value of st.len[1] is: <cfoutput>#st.len[1]#.</cfoutput></p> 
<p> 
<cfoutput> 
Substring is <b>[#Mid(testString,st.pos[1],st.len[1])#]</B> 
</cfoutput></p> 
<hr size = "2" color = "#0000A0"> 
<p>However, if you use parentheses to denote subexpressions in the regular 
expression, the first element contains the position and length of 
the first instance of the whole expression. The position and length 
of the first instance of each subexpression within will be included 
in additional array elements.</p> 
<p>For example: 
&lt;CFSET st1 = REFindNoCase("([[:alpha:]]+)[ ]+(\1)",testString,1,"True")&gt;</p> 
<cfset st1 = REFindNoCase("([[:alpha:]]+)[ ]+(\1)",testString,1,"True")> 

<p>The number of elements in each array is 
<cfoutput> 
#ArrayLen(st1.pos)# 
</cfoutput>.</p> 

<p>First whole expression match; position is 
<cfoutput> 
#st1.pos[1]#; length is #st1.len[1]#; 
whole expression match is <B>[#Mid(testString,st1.pos[1],st1.len[1])#]</B> 
</cfoutput></p> 

<p>Subsequent elements of the arrays provide the position and length of the 
first instance of each parenthesized subexpression therein.</p> 
<cfloop index = "i" from = "2" to = "#ArrayLen(st1.pos)#"> 
<p><cfoutput>Position is #st1.pos[i]#; Length is #st1.len[i]#; 
Substring is <B>[#Mid(testString,st1.pos[i],st1.len[i])#]</B> 
</cfoutput></p> 
</cfloop><br>

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy

Choose your region United States (Change)   Products   Downloads   Learn & Support   Company
Choose your region Close

Americas

Europe, Middle East and Africa

Asia Pacific

  • Brasil
  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Cyprus - English
  • Česká republika
  • Danmark
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Greece - English
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • Malta - English
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • Southeast Asia (Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam) - English
  • 台灣

Commonwealth of Independent States

  • Includes Armenia, Azerbaijan, Belarus, Georgia, Moldova, Kazakhstan, Kyrgyzstan, Tajikistan, Turkmenistan, Ukraine, Uzbekistan

Copyright © 2016 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

AdChoices