hmm... i guess i forgot to paste in the rest of the code... here it is
in all its ugly gory:

<cfset filename = rereplace(left(filename,
len(filename)-len(listlast(filename, "."))-1), "\W", "", "all") & "." &
listlast(filename, ".")>

it may be "eugh" and "ugly!", but it's a one-liner and takes care of .
inside filenames and any file extension length :)

if you still feel "eugh" about that one, how about this one:

<cfset filename = reverse(rereplace(listrest(reverse(filename), "."),
"\W", "", "all")) & "." & listlast(filename, ".")>

since this one is a tad bit shorter, will you consider it, maybe, just
"ugly" or just "eugh"?  :)

or how about this rereplace-only one:

<cfset filename = rereplace(rereplace(filename, "(.+?)(\.[^.]*$|$)",
"\1"), "\W", "", "all") & rereplace(filename, "(.+?)(\.[^.]*$|$)", "\2")>

(filename splitting regex courtesy of
http://www.movingtofreedom.org/2008/04/01/regex-match-filename-base-and-extension/)

:P

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/



Peter Boughton wrote:
>> better then just do something like
>>
>> rereplace(left(filename, len(filename)-len(listlast(filename, ".")-1),
>> "\W", "", "all")
>>     
>
> Eugh. Ugly!
>
> And doesn't restore the extension afterwards, so "my-image-name.png" would 
> become "myimagename" instead of "myimagename.png".
>
>   

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

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:316687
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to