RobLab - A script to remove all HTML tags
I mentioned this in a comment I wrote recently, so I thought it was time to add a script to RobLab that removes all HTML tags from an input string.
Enjoy! ![]()
I mentioned this in a comment I wrote recently, so I thought it was time to add a script to RobLab that removes all HTML tags from an input string.
Enjoy! ![]()
This always makes me wonder how I store my own content. WYSIWYG editors in CMS systems like FCKEditor asume that content is always stored with it’s layout formatting when in many cases this in not desired. Handy script, I’ll give it a look see.
If I’m not mistaken, you forgot to put more &s to the &’s, for the code example on that page:
/*
This line is optional, it replaces escaped brackets with real ones,
i.e. is replaced with >
*/
Uh, not I mean, there’s one line there sounds a bit weird:
i.e. < is replaced with < and > is replaced with >
Somehow your commenting system here seems to have problems with HTML entities..
Sorry
I prefer extending the string object with a new method:
String.prototype.stripHTML = function() {return this.replace(//g, ”);}
Exampe:
var foo = ‘hello robert…’;
alert(foo.stripHTML());
Less code, more handy…
/hbi
Hmm…My regular expression was deleted in the submission… a new try?
String.prototype.stripHTML = function() {return this.replace(/<.*?>/g, ”);}