Bhargavi
Bhargavi

Reputation: 851

how to find white space between the string in coldfusion

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

Answers (1)

duncan
duncan

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

Related Questions