I use this (note that you only need the first line for comments /*...*/ ):
#-- extract /* ... */ comment block # or lines of #... #... and //... //... if (preg_match("_^\s*/\*+(.+?)\*+/_s", $src, $uu) or (preg_match("_^\s*((^\s*(#+|//+)\s*.+?$\n)+)_ms", $src, $uu))) { $src = $uu[1]; } // Public Domain, not CC
It works well. But, like all regular expression solutions, it will fail in the case of the $PHP = "st/*rings" edge.
mario
source share