'引用Microsoft VBScript Regular Expressions 5.5 Dim s As String Dim p As String Dim reg As RegExp Dim mc As MatchCollection Dim m As Match Dim sms As SubMatches Dim i As Long
s = "我女朋友的生日是:1983-11-12" p = "([\d]{4})-([\d]{2})-([\d]{2})"
Set reg = New RegExp reg.Pattern = p Set mc = reg.Execute(s)
For Each m In mc MsgBox m.Value
Set sms = m.SubMatches For i = 0 To sms.Count - 1 MsgBox sms.Item(i) Next i Set sms = Nothing Next m Set mc = Nothing
Dim s As String
Dim p As String
Dim reg As RegExp
Dim mc As MatchCollection
Dim m As Match
Dim sms As SubMatches
Dim i As Long
s = "我女朋友的生日是:1983-11-12"
p = "([\d]{4})-([\d]{2})-([\d]{2})"
Set reg = New RegExp
reg.Pattern = p
Set mc = reg.Execute(s)
For Each m In mc
MsgBox m.Value
Set sms = m.SubMatches
For i = 0 To sms.Count - 1
MsgBox sms.Item(i)
Next i
Set sms = Nothing
Next m
Set mc = Nothing
Set reg = Nothing