View Single Post
 
Old 05-29-2012, 06:23 AM
tinfanide tinfanide is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default Regular Expressions: [!0-9] does not work???

Code:
Sub test()

Dim str As String
str = "str 9999 9999 str"

Dim RegExp As Object
Set RegExp = CreateObject("vbscript.regexp")

With RegExp
    .IgnoreCase = True
    .MultiLine = False
    .Pattern = "[!0-9]"
    .Global = True
End With

output = RegExp.Replace(str, "")
MsgBox output

Set RegExp = Nothing

End Sub
I can't understand why [a-z] can extract the numbers but why [!0-9] can't.
Reply With Quote