title: Using regular expression to parse text to prevent XSS
body: <p>I'm trying to parse a blob of text in <code>html</code> format, that only allow <code>bold</code> <code>&lt;b&gt;&lt;/b&gt;</code> and <code>italic</code> <code>&lt;i&gt;&lt;/i&gt;</code>.</p>
  
  <p>I know it nearly impossible to parse the html text to secure XSS. But given the constraints only to <code>bold</code> and <code>italic</code>, is that feasible to use regex to filter out the unnecessary tags?</p>
  
  <p>Thanks.</p>
  
  <p>--- Edit ---</p>
  
  <p>I meant to do the parsing on the client side, and render it right back.</p>
  
  <p>Please test your code against this, before jumping into conclusion.
  <a href="http://voog.github.io/wysihtml/examples/simple.html" rel="nofollow">http://voog.github.io/wysihtml/examples/simple.html</a></p>
  
  <p>BTW, why is the question itself get down voted?</p>
  
  <p>--- Closed ---</p>
  
  <p>I picked @Siguza 's answer to close this discussion.</p>