How about something like the following:
string2 = replace(string, '##', '', 'all');
count = len(string) - len(string2);
--Ben Doom
Programmer & General Lackey
Moonbow Software
: -----Original Message-----
: From: Everett, Al [mailto:[EMAIL PROTECTED]]
: Sent: Tuesday, October 15, 2002 6:16 PM
: To: CF-Talk
: Subject: Counting a character in a string (was: RE: Escaping the #
: symbol - Solved. New Question)
:
:
: 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
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community. http://www.fusionauthority.com/ads.cfm