×
Home About Us Products Services News Free Scripts Contact
news php scripts and software

JavaScript & DHTML example - How to strip HTML tags from a string with a simple regular expression using JavaScript?


JavaScript & DHTML - How to strip HTML tags from a string with a simple regular expression using JavaScript?

<HTML>
<HEAD>
<TITLE> Regular Expressions: stripping HTML tags </TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
var htstring = '<p align="Left"><b>Hello</b> <I>World</I></p>';
var stripped = htstring.replace(/(<([^>]+)>)/ig,"");
with (document)

{

   write ('Original string:' + htstring + '<br>');
   write ('Stripped string:<br><br>' + stripped); 

}

</SCRIPT>
</BODY>
</HTML>

Category: JavaScript & DHTML

 
<< Go back