Created
July 29, 2012 14:03
-
-
Save allex/3199078 to your computer and use it in GitHub Desktop.
removing c-styled comments using javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// vim: set ft=javascript | |
// removing c-styled comments using javascript | |
function removeComments(str) { | |
// Remove all C-style slash comments | |
str = str.replace(/(?:^|[^\\])\/\/.*$/gm, ''); | |
// Remove all C-style star comments | |
str = str.replace(/\/\*[\s\S]*?\*\//gm, ''); | |
return str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment