Posted By

rumremix on 10/13/10


Tagged

javascript html strip tags


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

bindaskhan2004hotmailcom
wirenaught


strip html tags from a string in Javascript


 / Published in: JavaScript
 

  1. <HTML>
  2. <HEAD>
  3. <TITLE> Regular Expressions: stripping HTML tags </TITLE>
  4. </HEAD>
  5. <BODY>
  6. <SCRIPT LANGUAGE="JavaScript">
  7. var htstring = '<p align="Left"><b>Hello</b> <I>World</I></p>';
  8. var stripped = htstring.replace(/(<([^>]+)>)/ig,"");
  9.  
  10. with (document) {
  11. write ('Original string:' + htstring + '<br>');
  12. write ('Stripped string:<br><br>' + stripped);
  13. }
  14. </SCRIPT>
  15. </BODY>
  16. </HTML>

Report this snippet  

You need to login to post a comment.