|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28690 PCRE Ungreedy glitch
Submitted: 2004-06-08 03:42 UTC Modified: 2004-09-18 01:00 UTC
Avg. Score:4.5 ± 0.5
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: swd120 at psu dot edu Assigned:
Status: No Feedback Package: PCRE related
PHP Version: 5.0.0RC2 OS: Windows XP, Apache 1.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
24 + 33 = ?
Subscribe to this entry?

 [2004-06-08 03:42 UTC] swd120 at psu dot edu
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:
	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>
	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>
	$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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-18 01:00 UTC] php-bugs at lists dot php dot net
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".
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Jun 06 03:03:42 2023 UTC