Using VB.net, I have a string that contains HTML. The HTML has several img tags within it. I am trying to grab an entire particular img tag based on the src containing specific characters (image002) so that I can replace the entire image tag with some new code.
What I have so far:
dim bodyContent as string = "<html><body><img src='image001.png'/><img src='image002.png'/></body></html>"
dim searchStr as string = "image002"
Dim imgRegex As New Regex("@""<img.*?src=""(?" & searchStr & ".*?)"".*?>""", RegexOptions.IgnoreCase)
bodyContent = imgRegex.Replace(bodyContent, "<div class='newCode'><a href='https://mywebsite.net/ViewAttachment'><img src='https://mywebsite.net/ViewThumbnail'></a></div>")
However, my RegEx is not correct. Any advice on to get the correct RegEx?