Skip to content

Instantly share code, notes, and snippets.

@kostasx
Forked from westc/getComments.js
Last active August 29, 2015 14:06
Show Gist options
  • Save kostasx/c3ba2d8912320300e1e6 to your computer and use it in GitHub Desktop.
Save kostasx/c3ba2d8912320300e1e6 to your computer and use it in GitHub Desktop.
(function(RGX_COMMENT, RGX_TRIM) {
getComments = function (fn, opt_trim) {
var comments = [];
(fn + '').replace(RGX_COMMENT, function(m, a, b, c) {
if (!c) {
m = a == undefined ? b : a;
comments.push(opt_trim ? m.replace(RGX_TRIM, '') : m);
}
});
return comments;
};
})(/\/\*([\s\S]*?)\*\/|(?:<\!--|\/\/)([^\r\n]*)|(["'])(?:[^\\\3]+|\\[\s\S])+\3/g, /^[\s\xA0]+|[\s\xA0]+$/g);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment