|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45479 wrong result when using preg_replace with /u and ungreedy *?
Submitted: 2008-07-10 16:53 UTC Modified: 2008-07-15 10:13 UTC
From: michael dot virnstein at brodos dot de Assigned:
Status: Closed Package: PCRE related
PHP Version: 5.2.6 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: michael dot virnstein at brodos dot de
New email:
PHP Version: OS:


 [2008-07-10 16:53 UTC] michael dot virnstein at brodos dot de
When i use preg_replace with the /u utf-8 modifier and an ungreedy search e.g. with *?, the result is different to a call without /u.

Reproduce code:
echo "without /u:". preg_replace('/^[^d]*?(d)?$/', '\\1', 'abc');
echo "<br>";
echo "with /u: ".preg_replace('/^[^d]*?(d)?$/u', '\\1', 'abc');

Expected result:
without /u:
with /u:

Actual result:
without /u:
with /u: abc


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-15 10:13 UTC]
Bug was in PCRE ( and not in PHP. Anyway the fix will be bundled with the next PCRE release.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Jul 31 06:01:24 2021 UTC