
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
regex-empty-conditional-comments
Advanced tools
Regular expression for matching HTML empty conditional comments
Regular expression for matching HTML empty conditional comments
This package is pure ESM. If you're not ready yet, install an older version of this program, 1.11.0 (npm i regex-empty-conditional-comments@1.11.0
).
npm i regex-empty-conditional-comments
import { strict as assert } from "assert";
import { emptyCondCommentRegex } from "regex-empty-conditional-comments";
// empty comment which was meant to target Outlook-only
assert.equal(
emptyCondCommentRegex().test(`<!--[if !mso]>
<![endif]-->`),
true,
);
// empty comment which was meant to target non-Outlook-only
assert.equal(
emptyCondCommentRegex().test(`<!--[if !mso]><!-- -->
<!--<![endif]-->`),
true,
);
assert.equal(
emptyCondCommentRegex().test(`<!--[if !mso]><!-- -->
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!--<![endif]-->`),
false,
);
assert.equal(
emptyCondCommentRegex().test(`<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
<o:PixelsPerInch>96</o:PixelsPerInch>
</o:OfficeDocumentSettings>
</xml><![endif]-->`),
false,
);
assert.equal(
emptyCondCommentRegex().exec("<html><!--[if !mso]><![endif]--><title>")[0],
"<!--[if !mso]><![endif]-->",
);
assert.deepEqual(
`<html> <!--[if !mso]><![endif]--> <title>text</title> <!--[if gte mso 9]>
<xml>
<![endif]-->`.match(emptyCondCommentRegex()),
["<!--[if !mso]><![endif]-->"],
);
Please visit codsen.com for a full description of the API.
To report bugs or request features or assistance, raise an issue on GitHub.
MIT License.
Copyright © 2010-2025 Roy Revelt and other contributors.
FAQs
Regular expression for matching HTML empty conditional comments
The npm package regex-empty-conditional-comments receives a total of 16,126 weekly downloads. As such, regex-empty-conditional-comments popularity was classified as popular.
We found that regex-empty-conditional-comments demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.