Note Submitter: giel dot berkers at gmail dot com
----
I am trying to build a function to pack a php script.
I am using regular expressions to delete comments and
whitespace:
<?php
// Delete //-comments:
$code = preg_replace('///.*/', '', $code);
// Delete /* */-comments:
$code = preg_replace('//*.**//m', '', $code);
// Delete excess whitespace:
$code = preg_replace('/ss+/', ' ', $code);
?>
I'm having trouble when removing /* */-comments. It doesn't
get the multiline mode. So this he will delete:
/* comment */
but not this:
/*
comment
*/
And when deleting the excess whitespace, also the EOL's get
deleted so my code is returned in one big string, and I
don't want that: I want to preserve the EOL's.
any suggestions what I am doing wrong here?
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|