Last active
May 21, 2020 19:31
-
-
Save ricealexander/6664770f7c3060cf490703db61cfbc37 to your computer and use it in GitHub Desktop.
Regex for stripping comments in a file
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
# Match all comments | |
\n?\s*\/\/\s.* | |
# \n? optional-linebreak for matching comments on their own line | |
# \s* matches any number of spaces preceeding // | |
# \/\/ matches // | |
# \s matches a single space after //. Lack of a space may indicate non-comment usage of // | |
# .* matches the content of the comment until the end of the current line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment