-
-
Save rana01645/04eaae346d806058101b77755303c8f5 to your computer and use it in GitHub Desktop.
Remove comments from file. Credit to Lambda's answer on Stack Overflow https://stackoverflow.com/a/2613945/5178499
This file contains 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
Remove all block comments and line comments: | |
(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/|[ \t]*//.*) | |
Remove block comments: | |
(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/) | |
Remove line comments: | |
([ \t]*//.*) | |
However, I should warn that this works only %99.99 of time. You might have a string variable defined in your file like: | |
String myStr = "/** I am not a comment */"; | |
This regex will turn this to: | |
String myStr = ""; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment