I'm working on a php application that scans through php files (phpPackageScan). Here's a sample output of a scan (WordPress 1.5):
http://www.osxcode.com/phpPackageScans/wordpress/
One of the things the script does before it searches for functions and cross references is strip comments. This is the regex I'm using:
That function removes the comments without removing the linebreaks. Now the problem is that if the php file contains something like:
And another /* */ comment somewhere below, it will strip everything between even if it isn't a comment ... obviously not a good thing.
In the above linked scan, you can see the problem if you view the comment of the rewrite_rules function inside /wp-includes/classes.php
Has anyone an idea how I could make that regex act more perfect? If possible without making the script too slow?
Fredi