How to remove HTML tags from a string in JavaScript

1 Answer

0 votes
let str = "<title>javascript</title> <p>c++</p> <a href='https://www.beforebuydomain.com'>beforebuydomain.com</a>"; 

str = str.replace(/<[^>]*>?/gm, '');

console.log(str);



/*
run:

"javascript c++ beforebuydomain.com"

*/

 



answered Nov 21, 2022 by avibootz

Related questions

...