Reputation: 851
I need to find the white space between a string in ColdFusion
for example
str="ha ppy"
Whitespace=4
i need to calculate how many white space between the str.
how to do that.
Upvotes: 0
Views: 1161
Reputation: 31930
A simple regex:
<cfset str="ha ppy">
<cfset spaces = reReplace(str, "\S+(\s+)\S+", "\1")>
<cfoutput>
<pre>spaces = [#spaces#]</pre><br>
#len(spaces)#
</cfoutput>
Upvotes: 1