Originally Posted by
RCGUA123
... Yes, you are correct I want to get: orange.jpg as I understand it, both patterns will get orange.jpg and both patterns will run at the same speed ...
I don't understand how you came to this conclusion.
Using as an example the string in post #14 with an image tag:
s = "<b>XXX</b><img width=""100%"" src=""orange.jpg"">"
As I see it, the first pattern
.Pattern = "<img\s.*?src=""([^""]+)"""
Get's you "orange.pjg" directly (just execute the code in post #14 to confirm it)
Now your suggestion for the pattern
If you use it with the same string, and get both the match and the submatch:
Sub Test()
Dim s As String
s = "<b>XXX</b><img width=""100%"" src=""orange.jpg"">"
With CreateObject("VBScript.RegExp")
.pattern = "<img(.*?)>"
MsgBox "Match: " & .Execute(s)(0)
MsgBox "Submatch: " & .Execute(s)(0).submatches(0)
End With
End Sub
The result is:
Match: <img width="100%" src="orange.jpg">
Submatch: width="100%" src="orange.jpg"
None of the two gives you "orange.jpg" directly.
I don't understand. Can you clarify?
Please post the code you used to test.