HTML Comment Regular Expression

A regular expression to match HTML Comments within your document.

/^<!--[\s\S]*?-->$/

What Is HTML Comment

Add a comment to an HTML document. An HTML comment begins with <! –– and the comment closes with ––>. HTML comments are visible to anyone that views the page source code, but are not rendered when the HTML document is rendered by a browser.

HTML Comment Examples:

  • <!– <div class=”demo”></div> –>

See Also: