Strip tags from string, is very useful when you want to extract text from string that contains HTML tags. You can remove the HTML tags from string using Regex in JavaScript. In the following code snippet, we will show you how to strip HTML tags from string using JavaScript.
Use JavaScript replace() method with Regex to remove HTML tags from string.
string.replace(/<\/?[^>]+(>|$)/g, "")
Code sample to strip tags from HTML string in JavaScript.
var str = "<p>Hello, <b>CodexWorld</b></p>";
var cleanText = str.replace(/<\/?[^>]+(>|$)/g, "");