regex - How to remove html comments from a string in Javascript -
so, have javascript string html markup assigned it.
now, want remove html comments , content string, ie occurrences of opening comment tag , closing comment tag; along comment inside in it.
so want remove occurences of
<!-- comment --> please note want ' comment ' removed well...
can me regex replace this...
thanks
like this
var str = `<div></div> <!-- comment --> <p></p> <!-- comment -->` str = str.replace(/<\!--.*?-->/g, ""); console.log(str)
Comments
Post a Comment