I am sure there are some nice slick regular expressions to do this, but I
just simply do this a very dumbed down way.

<cfset myVar = ReplaceNoCase(myVar , ",,,,,", ",", "ALL")>
<cfset myVar = ReplaceNoCase(myVar , ",,,,", ",", "ALL")>
<cfset myVar = ReplaceNoCase(myVar , ",,,", ",", "ALL")>
<cfset myVar = ReplaceNoCase(myVar , ",,", ",", "ALL")>

You could also write a loop to run until FindNoCase(myVar, ",,") EQ FALSE,
so you keep turning double commas, into single commas which will continue to
reduce the commas, until there are no matches.

Again, there is probably a RegEx way to do this, but I don't know RegEx off
the top of my head.

Regards,
David McGraw
Oyova Software, LLC
http://www.oyova.com


On Tue, Nov 2, 2010 at 8:34 AM, Richard White <rich...@j7is.co.uk> wrote:

>
> Hi, i need to replace all repeating commas in a string with only one comma,
> plus remove the trailing comma, have tried a few different routes
> unsuccessfully and would appreciate any input:
>
> for example i would the the string: 'Genns,,Dr,,,,Bish Stratford,,,'
> to become: 'Genns,Dr,Bish Stratford'
>
> thanks
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:338748
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to