php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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
Description:
------------
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:
---------------
<?php
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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-15 10:13 UTC] nlopess@php.net
Bug was in PCRE (http://bugs.exim.org/show_bug.cgi?id=732) and not in PHP. Anyway the fix will be bundled with the next PCRE release.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 12:01:36 2025 UTC