Regular Expression replacement not working RRS feed

  • Question

  • I am trying to use a regular expression to replace non-ascii characters on a file, and I'm afraid I've reached the end of my regex knowledge. 

    Here is the specific code

        'Set the Regular Expression paramaters
        Set RegEx = CreateObject("VBScript.Regexp")
        RegEx.Global = True
        RegEx.Pattern = "[^\u0000-\u007F]"
        RegEx.IgnoreCase = True
        'Replace the UTF-8 characters
        ReplacedText = RegEx.Replace(FileText, "\u0020")

    If I understand regular expressions correctly the pattern of "[^\u0000-\u007F]" should replace any character that is not an ascii character, and then replace it with a space (which I understand is "\u0020").  What am I doing wrong?
    Monday, April 27, 2015 8:36 PM

All replies

  • Simply use

    ReplacedText = RegEx.Replace(FileText, " ")

    Regards, Hans Vogelaar (

    Monday, April 27, 2015 8:46 PM