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

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -