Re: Replace special characters

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Mar 8, 9:50 pm, Gabriela <frohlin...@xxxxxxxxx> wrote:
On Mar 8, 6:53 pm, "Alex K. Angelopoulos" <aka(at)mvps.org> wrote:



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...@xxxxxxxxx> wrote in message

news:c3a12250-0107-45b8-a580-1668ca7c7119@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

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

That's all I needed. the little "[^ \w]" - thanks a lot!!

Ohhh, no, this helps only for English chars. When I've tried it with
other language's - it didn't work - they were removed by regular
expression. I need to support all literals in all languages...
Gabi.
.



Relevant Pages

  • Re: Replace special characters with regular expression
    ... I've tried to use regular expression with all special chars on ASCII ... I can't copy&paste to this post the string that is giving me trouble, ...
    (microsoft.public.scripting.vbscript)
  • Replace special characters with regular expression
    ... I've tried to use regular expression with all special chars on ASCII ... There are still special characters with "pass through" the regexp: ...
    (microsoft.public.scripting.vbscript)
  • Re: Replace special characters with regular expression
    ... I am trying to write a function that receives strings from all unicode ... I've tried to use regular expression with all special chars on ASCII ...
    (microsoft.public.scripting.vbscript)
  • 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. ... I've tried to use regular expression with all special chars on ASCII ...
    (microsoft.public.scripting.vbscript)
  • Re: Regex expression for numeric value with length check
    ... Based on the MSDN article mentioned by Bob, I write this regular expression ... It checks a string contains all numbers and is between ... Microsoft Online Community Support ... initial response from the community or a Microsoft Support Engineer within 2 ...
    (microsoft.public.dotnet.framework)