Should be able to replace any character other than a letter, or number, with
a single hyphen. This should do the trick:

<cfscript>
        function sesReplace(str) {
                // delete any character other than alpha-numeric
                var tmp = REReplaceNoCase(str,'[^[:alnum:] ]','','ALL');
                // replace all spaces with dashes
                return REReplaceNoCase(tmp,'[ ]+','-','ALL');
        }
</cfscript>

<cfset one = "This is the headline story!!">
<cfset two = "Let's not forget about special char$$$$$">
<cfset three = "Hyphens as in - should not appear 2 times in a row">

<cfoutput>
#sesReplace(one)#<br />
#sesReplace(two)#<br />
#sesReplace(three)#<br />
</cfoutput>



-----Original Message-----
From: Jeff Becker [mailto:[EMAIL PROTECTED] 
Sent: Monday, January 28, 2008 2:51 PM
To: CF-Talk
Subject: SPAM: SES UDF

Hi folks,

I'm experimenting with SES URLs for a company Intranet.

Basically I would like to take a string and turn it into alpha-numeric
separated by hyphens.

Therefore,
"This is the headline story!!" = "this-is-the-headline-story"

"Let's not forget about special char$$$$$" =
"lets-not-forget-about-special-char"

"Hyphens as in - should not appear 2 times in a row" =
"hyphens-as-in-should-not-appear-2-times-in-a-row"

Does anyone know if a UDF exists already.  I've looked at cflib. I've played
with REReplace, but can't find the correct regular expression to use.
Thanks to all for any help,
Jeff





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:297605
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to