Clean String Functions - Remove Unwanted Characters: Difference between revisions
Jump to navigation
Jump to search
Jkuehlthau (talk | contribs) (Created page with "Source: http://www.code-tips.com/2009/04/vbscript-string-clean-function-remove.html =Specify specific characters to remove or replace= <source lang="vbscript"> Function strCl...") |
(No difference)
|
Revision as of 19:15, 29 March 2016
Source: http://www.code-tips.com/2009/04/vbscript-string-clean-function-remove.html
Specify specific characters to remove or replace
Function strClean (strtoclean) Dim objRegExp, outputStr Set objRegExp = New Regexp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "[(?*"",\\<>&#~%{}+_.@:\/!;]+" outputStr = objRegExp.Replace(strtoclean, "-") objRegExp.Pattern = "\-+" outputStr = objRegExp.Replace(outputStr, "-") strClean = outputStr End Function
Remove all characters except specific characters, or a range of characters by allowing specific ranges (eg. a-z, A-Z, 0-9)
Function strClean (strtoclean) Dim objRegExp, outputStr Set objRegExp = New Regexp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "((?![a-zA-Z0-9]).)+" outputStr = objRegExp.Replace(strtoclean, "-") objRegExp.Pattern = "\-+" outputStr = objRegExp.Replace(outputStr, "-") strClean = outputStr End Function