title: vbscript function clean string only allow certain characters
body: <p>Until now I've been manually adding characters to replace that break my code.  I'd like to be a bit more proactive, so I found this function that is supposed to replace everything EXCEPT valid characters.  <strike>My first hurdle is that it doesn't seem to work.  The code below is my full test file and the MsgBox comes up blank.</strike></p>
  
  <p>My second question is about performance.  This function handles very, very large strings.  Will this method be considerably slower?  Anyone recommend anything else?</p>
  
  <pre><code>    Function CleanUp (input)
        Dim objRegExp, outputStr
        Set objRegExp = New Regexp
  
        objRegExp.IgnoreCase = True
        objRegExp.Global = True
        objRegExp.Pattern = "((?![a-zA-Z0-9]).)+"
        outputStr = objRegExp.Replace(input, "-")
  
        objRegExp.Pattern = "\-+"
        outputStr = objRegExp.Replace(outputStr, "-")
  
        CleanUp = outputStr
      End Function
  
      MsgBox (CleanUp("Test"))
  </code></pre>
  
  <p><strong>Edit: I'm stupid and just saw the variable mixup I did which was causing it to return nothing.  It is working now.  Will still accept input for performance question or better suggestions.</strong></p>