Re: REreplace function for special characters

2008-12-14 Thread Azadi Saryev
[q] FileName = rereplace(FileName, '(?!\.[^.]*$)\W', '', 'all') [/q] well, that is just beautiful! Azadi Saryev Sabai-dee.com http://www.sabai-dee.com/ ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic

Re: REreplace function for special characters

2008-12-12 Thread Azadi Saryev
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

Re: REreplace function for special characters

2008-12-12 Thread Peter Boughton
but it's a one-liner So? Unless you have a limited number of newlines, mindlessly shoving commands into a single line is really dumb; it reduces readability and achieves nothing. This is another thing that bugs me - people compressing code without thought - having the right amount of

Re: REreplace function for special characters

2008-12-11 Thread Peter Boughton
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.

Re: REreplace function for special characters

2008-12-11 Thread Don L
My follow-up posted last night didn't show up. So, I'm re-doing it now. Execellent, Peter, thank you very much. I'll use rereplace( FileName , '\W' , '' , 'all' ) On the extension stuff I have a way to address it. Don rereplace(foo, '[^\w]', '', 'all') will replace any non-alphanumeric

REreplace function for special characters

2008-12-10 Thread Don L
Regular Expression gurus. How to use the REreplace function to remove special characters including +, . in an image file name? The ReplaceList function may miss some unexpected special characters for we don't know what sort of special character may show up in a dynamically generated image

Re: REreplace function for special characters

2008-12-10 Thread Charlie Griefer
rereplace(foo, '[^\w]', '', 'all') will replace any non-alphanumeric character in 'foo' (assuming 'foo' is the file name). On Wed, Dec 10, 2008 at 1:41 PM, Don L [EMAIL PROTECTED] wrote: Regular Expression gurus. How to use the REreplace function to remove special characters including

Re: REreplace function for special characters

2008-12-10 Thread Don L
rereplace(foo, '[^\w]', '', 'all') will replace any non-alphanumeric character in 'foo' (assuming 'foo' is the file name). On Wed, Dec 10, 2008 at 1:41 PM, D Great. Thank you. I also found out that REreplace(str, [^a-zA-Z0-9],,all) would achieve the same result but yours seems more elegant

Re: REreplace function for special characters

2008-12-10 Thread Peter Boughton
rereplace(foo, '[^\w]', '', 'all') will replace any non-alphanumeric character No need to complicate things with an inverted character class. \W is same as [^\w] Also, this bugs me immensely: assuming 'foo' is the file name JUST USE THE VARIABLE FILENAME THEN! So: rereplace( FileName , '\W'

Re: REreplace function for special characters

2008-12-10 Thread Charlie Griefer
On Wed, Dec 10, 2008 at 3:02 PM, Peter Boughton [EMAIL PROTECTED] wrote: rereplace(foo, '[^\w]', '', 'all') will replace any non-alphanumeric character No need to complicate things with an inverted character class. \W is same as [^\w] fair enough. good catch. Also, this bugs me

Re: REreplace function for special characters

2008-12-10 Thread Peter Boughton
Hmmm, another thought... Don, when you say image file name, is there a file extension to worry about (i.e. jpg/png/etc) If so, you'll want to be doing something like this... rereplace( FileName , '(png|jpg|gif|tif|bmp)$' , '.\0' ) after the initial replacement, to restore the dot that will

Re: REreplace function for special characters

2008-12-10 Thread Peter Boughton
I also found out that REreplace(str, [^a-zA-Z0-9], ,all) would achieve the same result but yours seems more elegant (which seems to say just keep {words}), my CF env = cf8 or cf81 for Windows, does your solution have any dependency? No dependency. \W [^\w] and [^a-zA-Z0-9] will all work

Re: REreplace function for special characters

2008-12-10 Thread Peter Boughton
Sorry, typo. :( In CFML/rereplace it is treated as [a-zA-Z0-9_] (not the underscore). That should say note rather than not. Underscore is included in \w (and excluded from \W) which is not what some people might expect/want.

Re: REreplace function for special characters

2008-12-10 Thread Azadi Saryev
better then just do something like rereplace(left(filename, len(filename)-len(listlast(filename, .)-1), \W, , all) Azadi Saryev Sabai-dee.com http://www.sabai-dee.com/ Peter Boughton wrote: Hmmm, another thought... Don, when you say image file name, is there a file extension to worry about