|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77428 mb_ereg_replace() doesn't replace a substitution variable
Submitted: 2019-01-08 01:47 UTC Modified: 2019-01-08 09:09 UTC
From: shin1x1 at gmail dot com Assigned:
Status: Closed Package: mbstring related
PHP Version: 7.3.0 OS:
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: shin1x1 at gmail dot com
New email:
PHP Version: OS:


 [2019-01-08 01:47 UTC] shin1x1 at gmail dot com
The substitution variable of mb_ereg_replace() is not working when a substitution variable is preceded by a backslash

If you look at the output is different for prior to PHP 7.3.0.

Test script:

var_dump(mb_ereg_replace('(%)', '\\\1', 'a%c'));

Expected result:
string(4) "a\%c"

Actual result:
string(5) "a\\1c"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-08 09:09 UTC]
Hrm, both the old and the new behavior are incorrect. The result should be "a\1c" here. '\\\1' is \\1 after unescaping, which should be a literal \ followed by a literal 1.

Not sure what to do with this one... It looks like this function just did not support escaping backslashes previously, so we might just have to go back to that for BC reasons.
 [2019-01-08 09:22 UTC]
Automatic comment on behalf of
Log: Fixed bug #77428
 [2019-01-08 09:22 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 17 22:01:26 2024 UTC