I'm trying to use Outlook 2013 VBA to modify an email body by pulling out and replacing a < span> section. However, with multiple spans, I'm having trouble forcing the regex to only pick up one span.
Based on some other searches, I'm trying to use negative lookahead, but failing at it.
Result from below is: <span><span style = blah blah>Tags: test, test2</span>
Desired result is: <span style = blah blah>Tags: test, test2</span>
Code for test module:
Sub regextest()
Dim regex As New RegExp
Dim testStr As String
testStr = "a<span><span style=blah blah>Tags: test, test2</span></span>"
regex.pattern = "<span.*?(?:(span)).*?Tags:.*?</span>"
Set matches = regex.Execute(testStr)
For Each x In matches
Debug.Print x 'Result: <span><span style = blah blah>Tags: test, test2</span>
Next
End Sub
Thank you!