
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
html-comment-regex
Advanced tools
Regular expression for matching HTML comments
$ npm install --save html-comment-regex
var htmlCommentRegex = require('html-comment-regex');
htmlCommentRegex.test('<!DOCTYPE html><!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--><html lang="en"><head><meta charset="UTF-8"><title>Document</title></head><body></body></html>');
//=> true
htmlCommentRegex.test('<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Document</title></head><body></body></html>');
//=> false
MIT © Steve Mao
htmlparser2 is a fast and forgiving HTML/XML parser. It can be used to parse HTML and extract comments, among other elements. Unlike html-comment-regex, which uses regular expressions, htmlparser2 provides a more robust parsing solution that can handle malformed HTML.
Cheerio is a fast, flexible, and lean implementation of core jQuery designed specifically for the server. It can be used to parse HTML and manipulate the DOM, including extracting and removing comments. Cheerio offers more comprehensive DOM manipulation capabilities compared to the simple regex approach of html-comment-regex.
sanitize-html provides a library for cleaning up user-submitted HTML, including the ability to remove comments. It offers more advanced sanitization features, such as whitelisting allowed tags and attributes, which go beyond the basic comment matching provided by html-comment-regex.
FAQs
Regular expression for matching HTML comments
The npm package html-comment-regex receives a total of 1,328,895 weekly downloads. As such, html-comment-regex popularity was classified as popular.
We found that html-comment-regex demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.