Regular expression for matching JavaScript comments
This is pretty fragile and created for perf reasons where using a real parser would be overkill.
Install
$ npm install --save comment-regex
Usage
var commentRegex = require('comment-regex');
commentRegex().test('/* unicorn */\nvar foo = true;');
commentRegex().exec('/* unicorn */\nvar foo = true;')[2].trim();
'/* unicorn */\nvar foo = true;\nvar unicorn = "rainbows"; // rainbow'.match(commentRegex());
API
The contents of the comment is in the first submatch.
Returns a regex for matching line and block comments.
Returns a regex for matching line comments.
Returns a regex for matching block comments.
License
MIT © Sindre Sorhus