-2

Trying to remove all attributes except "src" from all html doms. like img or iframe.

Im using regex to do, but doesnt work;

    inp = Regex.Replace(inp, @"(<\s*[a-z][a-z0-9]*.*\s)(style\s*=\s*"".*?"")([^<>]*>)", "$1 $3", RegexOptions.Singleline | RegexOptions.IgnoreCase);

What's the problem that I cant see?

user2396307
  • 155
  • 2
  • 12

1 Answers1

0

My proposition would be:

Wouldn't it be simplier to find all html tags with pattern "<[^>]+>", having that just remove all that doesn't contain the string "src"?

Michał Turczyn
  • 30,583
  • 14
  • 41
  • 64