// To remove all HTML tags use the ".replace(/<[^>]+>/g, '')" method. let myHTML= ""; let strippedHtml = myHTML.replace(/<[^>]+>/g, ''); console.log(stripedHtml); // Jimbo. That's what she said
That's what she said
Here is what the above code is Doing:
1. The first part of the regular expression, <, matches the opening angle bracket of an HTML tag. 2. The second part of the regular expression, [^>]+, matches any character that is not a closing angle bracket.
3. The third part of the regular expression, >, matches the closing angle bracket of an HTML tag.
5. The second argument to the replace method is the string to replace the matches with. In this case, we’re replacing the matches with an empty string, which effectively removes the HTML tags from the string.