|  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
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 !
Your email address:
Solve the problem:
37 - 33 = ?
Subscribe to this entry?

 [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-2022 The PHP Group
All rights reserved.
Last updated: Mon Aug 08 01:05:45 2022 UTC