![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Replace special characters Hi, I am trying to write a function that receives strings from all unicode characters - and replaces all special characters (!@#$%^&*()><?...) with "-", but literals as is. I've tried to use regular expression with all special chars on ASCII table - but it still doesn't cover everything. I cannot use a "whitelist" (literals that are allowed) instead of a "blacklist" (special chars NOT allowed) - because I don't know the letters of all languages I'd like to support (English, Latin, Chinese, Arabic...). Any ideas what I can do? Thanks, Gabi. This is my "black list" regular expression code - but it does not succeed always... dim oreg_exp set oreg_exp = new RegExp 'oreg_exp.Pattern = "[^a-z0-9]" oreg_exp.Pattern = "([{}\(\)\^$&._%#!@=<>:;,~`'\’ \*\?\/\+\|\[\\\\]| \]|\-)" oreg_exp.IgnoreCase = true oreg_exp.global = true title = oreg_exp.replace (title,"-") Set oreg_exp = Nothing |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Replace special characters You haven't explained precisely what you mean by "special characters", but I'm guessing you mean anything that is not a word character and is not a space. For that, try this regular expression: oreg_exp.Pattern = "[^ \w]" "Gabriela" <frohlinger@xxxxxx> wrote in message news:c3a12250-0107-45b8-a580-1668ca7c7119@xxxxxx Quote: > Hi, > I am trying to write a function that receives strings from all unicode > characters - and replaces all special characters (!@#$%^&*()><?...) > with "-", but literals as is. > I've tried to use regular expression with all special chars on ASCII > table - but it still doesn't cover everything. > I cannot use a "whitelist" (literals that are allowed) instead of a > "blacklist" (special chars NOT allowed) - because I don't know the > letters of all languages I'd like to support (English, Latin, Chinese, > Arabic...). > Any ideas what I can do? > Thanks, > Gabi. > > This is my "black list" regular expression code - but it does not > succeed always... > > dim oreg_exp > set oreg_exp = new RegExp > 'oreg_exp.Pattern = "[^a-z0-9]" > oreg_exp.Pattern = "([{}\(\)\^$&._%#!@=<>:;,~`'\’ \*\?\/\+\|\[\\\\]| > \]|\-)" > oreg_exp.IgnoreCase = true > oreg_exp.global = true > title = oreg_exp.replace (title,"-") > Set oreg_exp = Nothing |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Replace special characters "Gabriela" <frohlinger@xxxxxx> wrote in message news:c3a12250-0107-45b8-a580-1668ca7c7119@xxxxxx Hi, I am trying to write a function that receives strings from all unicode characters - and replaces all special characters (!@#$%^&*()><?...) with "-", but literals as is. I've tried to use regular expression with all special chars on ASCII table - but it still doesn't cover everything. I cannot use a "whitelist" (literals that are allowed) instead of a "blacklist" (special chars NOT allowed) - because I don't know the letters of all languages I'd like to support (English, Latin, Chinese, Arabic...). Any ideas what I can do? Thanks, Gabi. This is my "black list" regular expression code - but it does not succeed always... dim oreg_exp set oreg_exp = new RegExp 'oreg_exp.Pattern = "[^a-z0-9]" oreg_exp.Pattern = "([{}\(\)\^$&._%#!@=<>:;,~`'\’ \*\?\/\+\|\[\\\\]| \]|\-)" oreg_exp.IgnoreCase = true oreg_exp.global = true title = oreg_exp.replace (title,"-") Set oreg_exp = Nothing I don't know much about Unicode, but I have played with it a little. Perhaps you should try going to http://unicode.org/. It has a wealth of info about Unicode and related issues. You might try its various site searches for the string 'special character' to get a better handle on what defines a 'special character', which might help lead you to an answer. -Paul Randall |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Replace special characters On Mar 8, 6:53*pm, "Alex K. Angelopoulos" <aka(at)mvps.org> wrote: Quote: > You haven't explained precisely what you mean by "special characters", but > I'm guessing you mean anything that is not a word character and is not a > space. For that, try this regular expression: > > oreg_exp.Pattern = "[^ \w]" > > "Gabriela" <frohlin...@xxxxxx> wrote in message > > news:c3a12250-0107-45b8-a580-1668ca7c7119@xxxxxx > Quote: > > Hi, > > I am trying to write a function that receives strings from all unicode > > characters - and replaces all special characters (!@#$%^&*()><?...) > > with "-", but literals as is. > > I've tried to use regular expression with all special chars on ASCII > > table - but it still doesn't cover everything. > > I cannot use a "whitelist" (literals that are allowed) instead of a > > "blacklist" (special chars NOT allowed) - because I don't know the > > letters of all languages I'd like to support (English, Latin, Chinese, > > Arabic...). > > Any ideas what I can do? > > Thanks, > > Gabi. Quote: > > This is my "black list" regular expression code - but it does not > > succeed always... Quote: > > dim oreg_exp > > set oreg_exp = new RegExp > > 'oreg_exp.Pattern = "[^a-z0-9]" > > oreg_exp.Pattern = "([{}\(\)\^$&._%#!@=<>:;,~`'\’ \*\?\/\+\|\[\\\\]| > > \]|\-)" > > oreg_exp.IgnoreCase = true > > oreg_exp.global = true > > title = oreg_exp.replace (title,"-") > > Set oreg_exp = Nothing |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Replace special characters with regular expression | VB Script | |||
| Password with special characters | Live Mail | |||
| Replace special characters in filenames - how? | PowerShell | |||
| Special Characters - how? | Vista General | |||
| How to run program with special characters | PowerShell | |||