Private Sub CommandButton1_Click()
Dim regEx As RegExp
Dim aMatch As Match
Dim Matches As MatchCollection
Dim patrn As String ' 搜索模式
Dim strng As String
Dim RetStr As String
patrn = "/s*(/w+)/s*=/s*(/d+),/s*(.*)"
strng = " aaa = 12, //xxxxxxx yyy zzz"
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(strng)
For Each aMatch In Matches
RetStr = RetStr + "Match found at position "
RetStr = RetStr + Str(aMatch.FirstIndex) + ". Match Value is '"
RetStr = RetStr + aMatch.Value + "'." + vbCrLf
MsgBox aMatch.SubMatches(0)
MsgBox aMatch.SubMatches(1)
MsgBox aMatch.SubMatches(2)
Next
End Sub