My code is:
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)
I want it to msgbox 37 and then msgbox me but it only msgboxes me.
Sorry, this answer is for Excel, but maybe it’ll help put you on the right track. VBA doesn’t support lookbehind, but you given the situation, there’s a way you can do this (using a substring of the original).
Here is the code. Assuming text was in cell A1, here’s what you’d write:
It would yield the result: “37, me“