There's always the brute force method:

<cfset count=0>
<cfloop from="1" to="#Len(myString)#" index="i">
 <cfif Mid(myString,i,1) EQ "##">
  <cfset count=count+1>
 </cfif>
</cfloop>

Not very elegant and for very large strings will not perform well.


> My new question is this. Occasionally the "Products" value 
> will have a #
> that I need to keep, so I'll need to split on the last # in 
> the string.
> Looking through the CF String Manipulation functions, I don't see
> anything that will return a count of a particular character. I haven't
> found any on cflib.org as well.
> 
> How could I find how many of a certain characters are in a string?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Reply via email to