Regular Expression for Removing HTML TagsPosted on By Addam Driver Thursday, June 21, 2012
Just incase anyone ever needs to remove HTML Tags in some string but want’s to keep the content in-between them. /(<([^>]+)>)/ig
var htmlText = "<h1><span>Get these tags away from me!</span></h1>";
var noHTML = /(<([^>]+)>)/ig; // regex for removing HTML tags
var clean = htmlText.replace(noHTML, ''); // remove all html tags
console.log(clean); // will return "Get these tags away from me!"
I hope this helps someone out there!