#28690 [Fbk->NoF]: PCRE Ungreedy glitch

From: Date: Fri, 17 Sep 2004 23:00:05 +0000
Subject: #28690 [Fbk->NoF]: PCRE Ungreedy glitch
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-66365@lists.php.net to get a copy of this message
ID: 28690 Updated by: php-bugs@lists.php.net Reported By: swd120 at psu dot edu -Status: Feedback +Status: No Feedback Bug Type: PCRE related Operating System: Windows XP, Apache 1.3 PHP Version: 5.0.0RC2 New Comment: No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". Previous Comments: ------------------------------------------------------------------------ [2004-09-10 12:47:04] nlopess@php.net Please try using this CVS snapshot: http://snaps.php.net/php5-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php5.0-win32-latest.zip ------------------------------------------------------------------------ [2004-06-08 03:42:31] swd120 at psu dot edu 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 this bug report at http://bugs.php.net/?id=28690&edit=1

« previous php.bugs (#66365) next »