Look at CountIt (http://www.cflib.org/udf.cfm?ID=304) on cflib.org, but use REFindNoCase instead of FindNoCase with the regexp in the code. There is an escape function for RegExp on cflib too.
Pascal
-----Oorspronkelijk bericht-----
Van: Tim Blair [mailto:[EMAIL PROTECTED]
Verzonden: vr 17/10/2003 13:59
Aan: CF-Talk
CC:
Onderwerp: RE: number of occurrences in a string.
Try this (watch the wrap):
<cffunction name="wordcount" returntype="numeric" output="yes"
hint="Counts the number of occurences of a given word in a given
string">
<cfargument name="word" type="string" required="yes" hint="The word
to look for">
<cfargument name="line" type="string" required="yes" hint="The
string to search through">
<cfset var wordarray =
refind("[^[:alpha:]](#arguments.word#)[^[:alpha:]]", arguments.line, 1,
TRUE)>
<cfif NOT wordarray.len[1]>
<cfreturn 0>
</cfif>
<cfreturn arraylen(wordarray.len)>
</cffunction>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

