
15

How to Remove HTML Tags from String using JavaScript
source link: https://www.codexworld.com/how-to/remove-html-tags-from-string-javascript/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to Remove HTML Tags from String using JavaScript
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, "");
Leave a reply
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK