babyshandy
9/24/2014 - 12:38 AM

http://stackoverflow.com/questions/182455/coldfusion-and-trailing-comma Check the rightmost character - if it's a comma, set the string to

http://stackoverflow.com/questions/182455/coldfusion-and-trailing-comma

Check the rightmost character - if it's a comma, set the string to a substring of the original, with length -1.

Trimming the string ensures that spaces after the trailing comma don't interfere with this method.

<cfset myStr = "hello, goodbye,">
<cfset myStr = trim(myStr)>

<cfif right(myStr, 1) is ",">
    <cfset myStr = left(myStr, len(myStr)-1)>
</cfif>