From:             swd120 at psu dot edu
Operating system: Windows XP, Apache 1.3
PHP version:      5.0.0RC2
PHP Bug Type:     PCRE related
Bug description:  PCRE Ungreedy glitch

Description:
------------
PCRE Ungreedy flag does not work in PHP5 RC2 w32 distribution.  same code
on linux distro 4.37 does not duplicate same result.

The flag remains greedy and doesn't replace the first value="ems" is
replaces the 2nd one(technically it replaces all of it but i thought it
would be easier to explain this way.) See source

Reproduce code:
---------------
        $string='/(name="One".*value="ems")/Usi';
        echo $string."<br>";
        $content = 'One:<select name="One" id="One">
        <option value="">&nbsp;</option>
        <option value="picas">picas</option>
        <option value="ems">ems</option>
        <option value="exs">exs</option>
        <option value="%">%</option>
        </select>
        Two<select name="Two" id="Two">
        <option value="">&nbsp;</option>
        <option value="picas">picas</option>
        <option value="ems">ems</option>
        <option value="exs">exs</option>
        <option value="%">%</option>
        </select>';
        $result = preg_match($string, $content);
        $replace ='\1 selected';
        $um = preg_replace($string,$replace,$content);
        echo "matches: ".$result."<br>".$um;

Expected result:
----------------
I expected value="ems" in the "one" select to become value="ems" selected.

Actual result:
--------------
value="ems" in the "two" select became value="ems" selected.



-- 
Edit bug report at http://bugs.php.net/?id=28690&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28690&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28690&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28690&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28690&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28690&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28690&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28690&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28690&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28690&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28690&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28690&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28690&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28690&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28690&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28690&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28690&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28690&r=float

Reply via email to