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

Find

Finds the first occurrence of a substring in a string, from a specified start position. The search is case-sensitive.

A number; the position of substring in string; or 0, if substring is not in string.

String functions

Find(substring, string [, start ])

FindNoCase, Compare, 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.

<cfoutput>
   <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>
</cfoutput>

Contents > CFML Reference > ColdFusion Functions > Find PreviousNext

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


Dylan_ said on May 16, 2005 at 10:26 AM :
Lothlauren -

You might try: <cfset Retval = Find("##", SearchString)>

You can escape the "#" character that way in CF.
MailManUSA said on May 21, 2005 at 9:08 PM :
Unless you made a typo in your comment, you wouldn't want to be searching for "Chr(34)" anyway. The ASCII equivalent of "#" is 35, so you'd want to do:

<cfoutput>

<cfset SearchString = "This ## should do the trick!">
<cfset Retval = Find( Chr(35), SearchString )>

The '##' sign is at position #Retval#.
</cfoutput>

Notice how, as Dylan_ suggested, escaped the '#' sign throughout the code.

Hope this helps.

Adam

 

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/functi80.htm