equivalent of instr in coldfusion

what is the equivalent of instr in coldfusion
StewSupportAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
_agx_Commented:
Display the index of substring:
      <cfset pos = findNoCase("i", "my test string")>
      <!--- show the substring position --->
      <cfoutput>
           The substring "i" was found at pos = #pos#<br/>
      </cfoutput>

Example of using the index as a boolean. The result is:  NOT found
     <cfset pos = findNoCase("X", "my test string")>
     <!--- If the pos <> 0, the substring was found --->
     <cfif pos>
          found
     <cfelse>
         NOT found
     </cfif>
0
SamuelShawCommented:
instr supports finding either a substring or a matching regular expression. ColdFusion provides different functions for both of these.
Find(substr, string, startPos)

Open in new window

This looks for substr in string, starting at index startPos (1 by default) and returns a) the one-based index of the first occurrence of substr in string at or after startPos or b) zero if it couldn't find substr in string at or after startPos. For more information about Find, check out the LiveDocs article.

FindNoCase(substr, string, startPos)

Open in new window

This works the same as Find, but performs a case-insensitive search. For more information, check out the LiveDocs article.

ReFind(regExp, string, startPos)

Open in new window

This looks for a match to regExp in string, starting at index startPos (1 by default) and returns a) the one-based index of the first match of regExp in string at or after startPos or b) zero if it couldn't find a match to regExp in string at or after startPos. For more information on ReFind, check out the LiveDocs article.
You also have ReFindNoCase, which works the same as ReFind, but is case-insensitive. Both functions have another optional parameter: a boolean parameter that, if true, means the function will return an object containing information about sub-matches found. The position and length of the full match and any matches to groups in the regular expression will be returned as arrays (len and pos) in an object.

One-based index?
A one-based index means that the first item in a list or an array is index #1. If I were to reference someArray[1], I would get the first value in the someArray array. Contrast this with zero-based languages (like JavaScript), where the first item in a list or array is index #0. In JavaScript, referencing someArray[1] would get the second value in the someArray array because the first item would actually be someArray[0].
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.