Advertisement
codecaine

Remove invalid characters from string

May 11th, 2018
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function RemoveInvalidCharacters(data As String) As String
  2. 'remove a character set from a string
  3.    Dim objRegex As Object
  4.     Set objRegex = CreateObject("vbscript.regexp")
  5.     With objRegex
  6.         .Global = True
  7.         'characters to be replaced
  8.        .Pattern = "[\<\>\*\'\,\$\#\@\.\""\?\!\/\[\]\:\|\\\/\?|]"
  9.         RemoveInvalidCharacters = .Replace(data, "")
  10.     End With
  11. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement