RE: [PHP] stripping comments
| From: | zzz | Date: | Sun, 05 Oct 2003 09:52:54 +0000 |
| Subject: | RE: [PHP] stripping comments | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-165083@lists.php.net to get a copy of this message | ||
Hey perfect Eugene, thanks
-----Original Message-----
From: Eugene Lee [mailto:list-php-1@fsck.net]
Sent: October 5, 2003 5:14 AM
To: Php-General@Lists.Php.Net
Subject: Re: [PHP] stripping comments
On Sun, Oct 05, 2003 at 04:46:16AM -0400, zzz wrote:
:
: I'm trying to strip comments out of my code. I can get it to strip one
: section of comments but the problem comes in when I have more then one
: comment section to strip.
:
: I am using this: $code = preg_replace('/\/*(.*?)*\//is', '$1', $code) and
: need help fixing my regex.
:
: example:
: ========
: code 1
: /* comment 1 */
: code 2
: /* comment 2 */
: code 3
:
: result (bad):
: =============
: code 1
: code 3
:
: result (good):
: ==============
: code 1
: code 2
: code 3
How about this:
$code = preg_replace('|/\*.*\*/|msU', '', $code);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php