How to remove HTML tags from string nodejs?
I need to remove HTML tags from a string in nodejs.
Is there any module that can be used for this? The code below will remove all tags (including the < and >) from a given string. Const stripTags = (s) => ;. It will work with most strings including XML, because it removes the only character that is allowed in a tag (<), and not in a text node (>). It also works with HTML, because both allow & or " or > or " and the only thing that are allowed in a tag are >, <, " or &, and none of these are inside a text node.
Since you tagged your question as nodejs, here's how the same thing can be done in javascript: String.prototype.stripTags = function () ;
You can also use replace function. Str.replace(/(<.>)
Related Answers
How to remove HTML inside element in jQuery?
I have a string which contains HTML tags. I need to re...
What is Web design examples?
You can find old-school designers who insist they don't. And they'...
What is JavaScript extension?
I am working on an experimental project that uses JavaScript...