ASP

ASP Variables Strings Form Arrays 2D Array Loop IF Cookies Dates Dictionaries SQL Numbers Files JSON Database Regular Expression ExecuteGlobal Recordset ServerVariables Bugs ADO AJAX XML Chilkat
O O

Weather Controls

Time Of Day
Rain
Wind Speed
Wind Direction
Clouds

ASP : Regular Expression

2018-09-26

Remove Weird characters.

Function strClean (strtoclean)
    Dim objRegExp, outputStr
    Set objRegExp = New Regexp
    objRegExp.IgnoreCase = True
    objRegExp.Global = True
    objRegExp.Pattern = "((?![a-zA-Z0-9s]).)+"
    outputStr = objRegExp.Replace(strtoclean, "")
    strClean = Trim(outputStr)
    Set objRegExp = Nothing
End Function

Return on ly a number

Function retNumber (str)
    Dim ore, r
    Set ore = New Regexp
    ore.IgnoreCase = True
    ore.Global = True
    ore.Pattern = "D"
    r = ore.Replace(str, "")
    if len(r) > 0 then 
        retNumber = clng(Trim(r))
    else 
        retNumber = -1
    end if
    Set ore = Nothing
End Function

Reference

http://www.code-tips.com/2009/04/vbscript-string-clean-function-remove.html

https://www.tutorialspoint.com/vbscript/vbscript_reg_expressions