[Fwd: Re: [PEAR-DEV] [PEPr] Comment on Web Services::Services_JSON]
| From: | bertrand Gugger | Date: | Sat, 15 Oct 2005 12:47:54 +0000 |
| Subject: | [Fwd: Re: [PEAR-DEV] [PEPr] Comment on Web Services::Services_JSON] | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-40210@lists.php.net to get a copy of this message | ||
Hey list,
sorry, forgot to forward this one :)
-------- Original Message --------
Subject: Re: [PEAR-DEV] [PEPr] Comment on Web Services::Services_JSON
Date: Thu, 13 Oct 2005 20:57:33 +0200
From: bertrand Gugger <bertrand@toggg.com>
To: Michal Migurski <mike@teczno.com>
References: <20051013123019.35353.qmail@pb12.pair.com> <434E6090.5000408@toggg.com> <F9B885FD-92EE-421E-94D2-044608DF04D7@teczno.com>
re
Michal Migurski wrote:
On Oct 13, 2005, at 6:26 AM, bertrand Gugger wrote:Deconstructing ? [bertrand@ancilla test]$ php uncomment.php Content-type: text/html X-Powered-By: PHP/4.3.11 source: // a first line comment yo = 0; // end of line comment ahlal = false; /* wooo ! multiline comment*/ hehe /* try */ = /* hope*/ "Mhhh..." ; //that is right oki = 'et /* bad comment */'; cool = '// de toute façon'; ah = ' qu\'y a-t-il?'; rien = "rien, y'a \"rien\""; uncommented: yo = 0; ahlal = false; hehe = "Mhhh..." ; oki = 'et /* bad comment */'; cool = '// de toute façon'; ah = ' qu\'y a-t-il?'; rien = "rien, y'a \"rien\""; FINI ! [bertrand@ancilla test]$ cat uncomment.php <?php function uncomment($source) {Where would this go - reduce_string() ? It doesn't work in that location - perhaps you had something else in mind. Would you mind deconstructing the pattern a little?Just for uncommenting the sources, why not use : [code] preg_replace(should have been:'#(?:/\*(?:(?R)|.)*\*/|//.*$)|(([\'"])(?:.*)(?<!\\)|([^ \'"/]+))#msU','#(?:/\*(?:(?R)|.)*\*/|//.*$)|(([\'"])(?:.*)(?<!\\\\)\2|([^ \'"/]+))#msU'
return preg_replace(
'#(?:/\*(?:(?R)|.)*\*/|//.*$)|(([\'"])(?:.*)(?<!\\\\)\2|([^\'"/]+))#msU',
"$1", $source);
}
ini_set('display_errors', true);
error_reporting(E_ALL);
$source = <<<EOS
// a first line comment
yo = 0; // end of line comment
ahlal = false; /* wooo !
multiline comment*/
hehe /* try */ = /* hope*/ "Mhhh..." ; //that is right
oki = 'et /* bad comment */';
cool = '// de toute façon';
ah = ' qu\\'y a-t-il?';
rien = "rien, y'a \\"rien\\"";
EOS;
echo "\nsource:\n" . $source;
echo "\nuncommented:\n" . uncomment($source);
echo "\n\nFINI !\n";
?>
[bertrand@ancilla test]$
Deconstructing what ? Your poor regexpes ?
I'm sad you called for what so early.
à+
--
bertrand "toggg" Gugger