0

It would be great if someone could help me with the regex. This is my code:

Regex.Replace("<_img src=\"abc.png\" /><_img class=\"shwimg\" alt=\"\" width=\"20\" height=\"20\" src=\"/images/img/do.png\" />",
                    "<_img .*? src=\"/images/img/do.png\" />", string.Empty)

I need to remove the occurrence of the string:

<_img class="shwimg" alt="" width="20" height="20" src="/images/img/do.png" />

The order of the occurence of

class="shwimg" alt="" width="20" height="20"

may vary, hence I've given .*? in the pattern. However, the pattern I've given doesnt work and I'm not able to replace the string.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Mac
  • 11
  • 1

1 Answers1

0

Is this the regex you're looking for?:

<_img [^>]*src="/images/img/do.png" />

(here's the same with escaped double-quotes, ready for use in your Regex.Replace call):

"<_img [^>]*src=\"/images/img/do.png\" />"
Kamal
  • 7,160
  • 2
  • 21
  • 12