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
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.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2020 The PHP Group
All rights reserved.
Last updated: Mon Aug 10 16:01:23 2020 UTC