We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

cochambre on 08/02/06


Tagged

html strip String tags remove clean


Versions (?)


Who likes this?

3 people have marked this snippet as a favorite

nicolaspar
nutella
vali29


Strip HTML tags from string


Published in: JavaScript 


  1. function stripHtml(s) {
  2. return s.replace(/\\&/g, '&amp;').replace(/\\</g, '&lt;').replace(/\\>/g, '&gt;').replace(/\\t/g, '&nbsp;&nbsp;&nbsp;').replace(/\\n/g, '<br />');
  3. }

Report this snippet 

You need to login to post a comment.