1var htmlString= "<div>\n <h1>Hello World</h1>\n <p>This is the text that we should get.</p>\n <p>Our Code World © 2017</p>\n </div>";
2
3var stripedHtml = htmlString.replace(/<[^>]+>/g, '');
4var decodedStripedHtml = he.decode(stripedHtml);
5
6// Hello World
7// This is the text that we should get.
8// Our Code World © 2017
9console.log(stripedHtml);
10
11// Hello World
12// This is the text that we should get.
13// Our Code World © 2017
14console.log(decodedStripedHtml);
1var myString = "<table><tr><td>Some text ...<a href='#'>label...</a></td></tr></table";
2myString += "<table><tr><td>Some text ...<a href='#'>label...</a></td></tr></table";
3myString += "<table><tr><td>Some text ...<a href='#'>label...</a></td></tr></table";
4
5console.log(myString);
6
7var anchorTagsRemoved = myString.replace(/<a.*>.*?<\/a>/ig,'');
8console.log(anchorTagsRemoved);