/ Published in: JavaScript
Expand |
Embed | Plain Text
var htmlStr = '<a>clicke me</a><p><b>block1</b></p>1 2g'; var s = htmlStr.replace(/<[^>]*>/ig,''); var s = s.replace(/[(\/>)<]/ig,''); alert(s);
Comments
Subscribe to comments
You need to login to post a comment.

Regular Expressions: stripping HTML tags
var htstring = '
Hello World
'; var stripped = htstring.replace(/(]+)>)/ig,"");with (document) { write ('Original string:' + htstring + ''); write ('Stripped string:' + stripped); }
Regular Expressions: stripping HTML tags var htstring = '
Hello World
'; var stripped = htstring.replace(/(<([^>]+)>)/ig,"");with (document) { write ('Original string:' + htstring + ''); write ('Stripped string:' + stripped); }
sorry i wanted to post the whole code but all u need is just to write a SINGLE line var stripped = htstring.replace(/(]+)>)/ig,"");
and your string may contain any html code like
tag or anything