title: How can I Strip all regular html tags except <a></a>, <img>(attributes inside) and <br> with javascript?
body: <p>When a user create a message there is a multibox and this multibox is connected to a design panel which lets users change fonts, color, size etc.. When the message is submited the message will be displayed with html tags if the user have changed color, size etc on the font.</p>
  
  <p>Note: I need the design panel, I know its possible to remove it but this is not the case :)</p>
  
  <p>It's a Sharepoint standard, The only solution I have is to use javascript to strip these tags when it displayed. The user should only be able to insert links, images and add linebreaks.</p>
  
  <p>Which means that all html tags should be stripped except <code>&lt;a&gt;&lt;/a&gt;</code>, <code>&lt;img&gt;</code> and <code>&lt;br&gt;</code> tags.</p>
  
  <p>Its also important that the attributes inside the the <code>&lt;img&gt;</code> tag that wont be removed. It could be isplayed like this:</p>
  
  <pre><code>&lt;img src="/image/Penguins.jpg" alt="Penguins.jpg" style="margin:5px;width:331px;"&gt;
  </code></pre>
  
  <p>How can I accomplish this with javascript?</p>
  
  <p>I used to use this following codebehind C# code which worked perfectly but it would strip all html tags except <code>&lt;br&gt;</code> tag only.</p>
  
  <pre><code>public string Strip(string text)
  {
     return Regex.Replace(text, @"&lt;(?!br[\x20/&gt;])[^&lt;&gt;]+&gt;", string.Empty);
  }
  </code></pre>
  
  <p>Any kind of help is appreciated alot</p>