On 10/18/07, Steve Sequenzia <[EMAIL PROTECTED]> wrote:
> I need to take a string and replace all the spaces with dashes. I tried using 
> the replace function but I am having issues with strings that have multiple 
> spaces next to each other and/or a space or spaces at the end. Here is what I 
> have:
>
> <cfset dirName = #Replace(String," ", "-", "ALL")#>

your code should be replacing trailing strings.

but if you're looking to replace multiple spaces with a single dash,
you'll need a regex.

<cfset dirname = rereplace(string, '[[:space:]]+', '-', 'all') />

the + means "one or more" (and as with your code, should also handle
trailing spaces).

-- 
Charlie Griefer

================================================
"...All the world shall be your enemy, Prince with a Thousand Enemies,
and whenever they catch you, they will kill you. But first they must catch
you, digger, listener, runner, prince with a swift warning.
Be cunning and full of tricks and your people shall never be destroyed."

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion is delivering applications solutions at at top companies 
around the world in government.  Find out how and where now
http://www.adobe.com/cfusion/showcase/index.cfm?event=finder&productID=1522&loc=en_us

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:291467
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