Re: Filter string to remove non-utf-8 characters

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



BTW, I tried this:


testVar = "as§d asdf... "

'Create a regular expression object
Dim regEx
Set regEx = New RegExp

'The global property tells the RegExp engine to find ALL matching
'substrings, instead of just the first instance. We need this to be
true.
regEx.Global = true

'Our pattern tells us what to find in the string... In this case, we
find
'anything that isn't a numerical character, or a lowercase or
'uppercase alphabetic character
regEx.Pattern = "[^0-9a-zA-Z]"

'Use the replace function of RegExp to clean the username. The replace
'function takes the string to search (using the Pattern above as the
'search criteria), and the string to replace any found strings with.
'In this case, we want to replace our matches with nothing (''),
'as the matching characters will be the ones we don't want in our
username.
dim username
username = regEx.Replace(testVar, "")


But, writing testVar still contains §.

.



Relevant Pages

  • Re: Filter string to remove non-utf-8 characters
    ... 'The global property tells the RegExp engine to find ALL matching ... 'Our pattern tells us what to find in the string... ... 'Use the replace function of RegExp to clean the username. ...
    (microsoft.public.scripting.vbscript)
  • Re: Perl Substitution Begining Line
    ... apparently read the usage of \w correctly as I thought it was matching ... the s/// operator is not a regexp, ... double-quotish string, $ means the start of a variable. ... your shell to leave that alone and pass it directly to Perl. ...
    (perl.beginners)
  • Re: Possible bug with StringScanner class
    ... >>> I'm not sure if this is a bug or intentional behavior, ... >> the string for matching. ... In addition, the regexp that scan ...
    (comp.lang.ruby)
  • Re: Possible bug with StringScanner class
    ... > the string for matching. ... In addition, the regexp that scan ... > Do you Yahoo!? ...
    (comp.lang.ruby)
  • Re: Regexp, ***= and subexpressions
    ... specified that the user's input be treated as a literal string rather than ... -exact] in cases where regexp isn't required:P ... Seems to be that regexp can't match word boundaries at "non-word" ... But now Earth has rotated and I can get back to sleep. ...
    (comp.lang.tcl)