VBScript替代PHP preg_match

时间:2013-06-20 23:24:53

标签: vbscript

我需要重写以下PHP代码段(从提供的字符串中过滤掉任何非数字字符);

$new_string = preg_replace("/[^0-9]/", "", $old_string)

进入VBScript。有什么建议吗?

1 个答案:

答案 0 :(得分:2)

Function repNum(myString)
    Set RegularExpressionObject = New RegExp
    With RegularExpressionObject
        .Pattern = "[^0-9]"
        .IgnoreCase = True
        .Global = True
    End With
    repNum = RegularExpressionObject.Replace(myString, "")
    Set RegularExpressionObject = nothing
End Function