Last active
July 1, 2021 00:05
-
-
Save natebass/90b5ca184ac922f5d853 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 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
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 = ""; |
Awesome, mate. Works like a charm. Just regex replace and... Voiláa. No need for specific software or anything else. Thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice, thanks!