From: shahir_reza2001 at yahoo dot com
Operating system: FreeBSD 4.11
PHP version: 5.1.2
PHP Bug Type: PHP options/info functions
Bug description: preg_replace
Description:
------------
Preg_replace wont replace properly
Reproduce code:
---------------
$patterns = '{([\w_]+)(\s*</font>)'.
3 '(\s*<font\s+color="'.$keycol.'">\s*\()}m';
4 $replacements = '<a class="code" title="View manual page for
$1" href="'.$manual.'$1" target="_blank">$1</a>$2$3';
5 return preg_replace($patterns, $replacements, $code);
example using php4+:
downlaod any file from http://www.codedb.org/files.php?lang=php
and it will underline the add <a href> to the php functions
Expected result:
----------------
<br /></font><font color="#007700">function </font><font
color="#0000BB"><a class="code"
href="http://www.php.net/manual-lookup.php?lang=en&pattern=isemail"
title="View manual page for isemail"
target="_blank">isemail</a></font><font color="#007700">(</font><font
color="#0000BB">$mail</font><font color="#007700">)
<br />{
<br /> if (</font><font color="#0000BB"><a class="code"
href="http://www.php.net/manual-lookup.php?lang=en&pattern=eregi"
title="View manual page for eregi" target="_blank">eregi</a></font><font
color="#007700">(</font><font
color="#DD0000">"[EMAIL PROTECTED],4}$"</font><font
color="#007700">,</font><font color="#0000BB">$mail</font><font
color="#007700">))
<br /> {
<br /> return </font><font
color="#0000BB">1</font><font color="#007700">;
<br /> }
<br /> else {
<br /> return </font><font
color="#0000BB">0</font><font color="#007700">;
<br /> }
<br />}
<br /></font><font color="#0000BB">?></font>
Actual result:
--------------
<br /></span><span style="color: #007700">function </span><span
style="color: #0000BB">isemail</span><span style="color:
#007700">(</span><span style="color: #0000BB">$mail</span><span
style="color: #007700">)
<br />{
<br /> if (</span><span style="color:
#0000BB">eregi</span><span style="color: #007700">(</span><span
style="color:
#DD0000">"[EMAIL PROTECTED],4}$"</span><span
style="color: #007700">,</span><span style="color:
#0000BB">$mail</span><span style="color: #007700">))
<br /> {
<br /> return </span><span style="color:
#0000BB">1</span><span style="color: #007700">;
<br /> }
<br /> else {
<br /> return </span><span style="color:
#0000BB">0</span><span style="color: #007700">;
<br /> }
<br />}
<br /></span><span style="color: #0000BB">?></span>
--
Edit bug report at http://bugs.php.net/?id=36437&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=36437&r=trysnapshot44
Try a CVS snapshot (PHP 5.1):
http://bugs.php.net/fix.php?id=36437&r=trysnapshot51
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=36437&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=36437&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=36437&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=36437&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=36437&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=36437&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=36437&r=support
Expected behavior: http://bugs.php.net/fix.php?id=36437&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=36437&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=36437&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=36437&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36437&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=36437&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=36437&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=36437&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=36437&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=36437&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=36437&r=mysqlcfg