View comments | RSS feed
Contents > CFML Reference > ColdFusion Functions > FindNoCase PreviousNext

FindNoCase

Finds the first occurrence of a substring in a string, from a specified start position. If substring is not in string, returns zero. The search is case-insensitive.

The position of substring in string; or 0, if substring is not in string.

String functions

FindNoCase(substring, string [, start ])

Find, CompareNoCase, FindOneOf, REFind, Replace

Parameter

Description

substring

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

string

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

start

Start position of search.

<cfset stringToSearch = "The quick brown fox jumped over the lazy dog.">
#find("the",stringToSearch)#<br>
#find("the",stringToSearch,35)#<br>
#find("no such substring",stringToSearch)#<br>
<br>
#findnocase("the",stringToSearch)#<br>
#findnocase("the",stringToSearch,5)#<br>
#findnocase("no such substring",stringToSearch)#<br>
<br>
#findoneof("aeiou",stringToSearch)#<br>
#findoneof("aeiou",stringToSearch,4)#<br>
#findoneof("@%^*()",stringToSearch)#<br>


Contents > CFML Reference > ColdFusion Functions > FindNoCase PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


tzimmerman said on Apr 29, 2004 at 12:17 PM :
Running the following will give a good idea of how the FIndNoCase function works:

<cfset stringToSearch = "The quick brown fox jumped over the lazy dog.">

stringToSearch = <cfoutput>#stringToSearch#</cfoutput><br>
<p>
Find Function:<br>
Find("the",stringToSearch) returns <cfoutput>#find("the",stringToSearch)#</cfoutput><br>
<p>
FindNoCase Function:<br>
FindNoCase("the",stringToSearch) returns <cfoutput>#FindNoCase("the",stringToSearch)#</cfoutput>

The Find function will return 33 as the first position found because "the" is lower case. The FindNoCase function will return 1 as the first postion as the case is ignored.
esch said on Aug 12, 2004 at 1:33 PM :
If substring is longer than string, you will get 'StackOverflowError'. This error will not be caught by a try/catch block and will just error out with a very ugly and non-descript message.
dontbugme@email.co.uk said on Oct 1, 2004 at 3:34 AM :
Is the start position 0-based or 1-based ? Go figure.
dontbugme@email.co.uk said on Oct 1, 2004 at 3:39 AM :
Actually positions in string seem to be 1-based. It can be deduced from the fact that 0 is used when substring is not found (instead of substring position), so 0 cannot be a substring position.
However documentation shoud clearly mention this. Because programmers familiar with most other programming languages would expect offsets to be 0-based.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/functi81.htm