This shows use cases where a simple regex like the one on StackOverflow cannot be relied upon for 100% accuracy in detecting comments in code.
var foo = "There's no way to tell that this /* is not the beginning of a comment";
var bar = "There's no way to tell that this */ is not the end of a comment";
var baz = "There's no way to tell that this // is not a single line comment";
var buz = "Matters get much worse when there are escaped \" quotes /* inside the string. Definitely need a parser.";
var fiz = `And there is
really no way to // detect that these are
/* not real comments */
within a JS template literal.
`;
var foo = {
bar:// regex cannot distinguish "bar://" from "http://"
"the value for bar is dangling down here - this is valid"
};
{
include: [
"src/**/*.js
],
exclude: [
"src/**/*.test..js
]
}
Thank you for the comment @Tresdin - I have updated the regex to allow for that type of code, and I updated the test page to reflect this change. Thanks for helping improve this amazing regex!!