Skip to content

Instantly share code, notes, and snippets.

@ricealexander
Last active May 21, 2020 19:31
Show Gist options
  • Save ricealexander/6664770f7c3060cf490703db61cfbc37 to your computer and use it in GitHub Desktop.
Save ricealexander/6664770f7c3060cf490703db61cfbc37 to your computer and use it in GitHub Desktop.
Regex for stripping comments in a file
# 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