by Matt Perkins.
Sure! I typed up this example in the editor so I can't garuntee they'll work 100%, but the functions below are what I'm using. I can't take credit for the Regex, I think I found it on stackoverflow a while back.
// Example
var summary = "<h1>Some title</h1><p>This is <span>>cool!<</span></p>"
var cleanedSummary = removeEntity(removeTags(summary));
// cleanedSummary will be "Some title This is cool!"
// Remove all HTML tags from a string
function removeTags(str) {
return str.replace(/(<([^>]+)>)/ig, '');
}
// Remove all HTML entities such as >
function removeEntity(str) {
return str.replace(/(&(#?)(?:[a-z\d]+|#\d+|#x[a-f\d]+);)/ig, '');
}