Nevertheless, if you just need to clean the string, this is a nice Javascript function which clean all empty HTML tags.
String.prototype.htmlTrim = function () {
return this.replace(/<(\w+)>\s*\n*\t*( )*\s*\n*\t*<\/\1>/, '');
};
The usage is just
var cleanString = "<p></p><p>My String</p>".htmlTrim();
That will return "<p>My String</p>". Here's an example of the Regex.
0 comments:
Post a Comment