我的代碼是:正則表達式(VBA) - 重複模式
Dim regEx, retVal
' Create regular expression.
set text = "update my_table set time4 = sysdate, randfield7 = 'FAeKE', randfield3 = 'MyE', the_field9 = 'test' WHERE my_key = '37', tymy_key = 'me';"
Set regEx = CreateObject("vbscript.regexp")
regEx.pattern = ".+where.+ \'(.+)\'+.*;"
regEx.IgnoreCase = True
regEx.MultiLine = True
regEx.Global = True
Set objRegexMC = regEx.Execute(text)
MsgBox objRegexMC(0).SubMatches(0)
我希望它MSGBOX 37,然後MSGBOX我,但它只是msgboxes我。
兩階段正則表達式是一個很好的解決方法。我喜歡在將'seperator&.Item(i).submatches.Item(j)'結合到'result'之前, – brettdj