I am trying to find a way to shrink my PHP/JavaScript code by removing all of my single and multiple line comments. Currently I have the single line removal working but I can not figure out how to make my multiple line comments remove. I have tried the following regular expressions:
\/\*[^\*\/]*\*\/
\/\*[^.\/]*\*\/
And many others. The current expression I am using to find the single lines and failing the multi lines is (\/\/[^\n]*\n|\/\*[^\*\/]*\*\/)
Expression Requirements
- The expression must be in Perl
- The expression must not stop at
//
inside the multiline comment (ie. http://url.com) - The expression must be able to find both single and multiline comments
- The expression can be used to find the beginning and end of any multiline PHP/JavaScript comment.
A sample of code you can test on that I will need it for can be found here
Thank you in advance.