|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-09-10 12:47 UTC] nlopess@php.net
[2004-09-18 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 14:00:01 2025 UTC |
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=""> </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=""> </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.