php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49399 mb_ereg_replace() '\b' fails with mbstrings
Submitted: 2009-08-28 13:17 UTC Modified: 2009-12-13 22:15 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: manfred at mabuweb dot com Assigned: moriyoshi (profile)
Status: Not a bug Package: mbstring related
PHP Version: 5.2.10 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: manfred at mabuweb dot com
New email:
PHP Version: OS:

 

 [2009-08-28 13:17 UTC] manfred at mabuweb dot com
Description:
------------
mb_ereg_replace() and mb_eregi_replace() misinterpretate MBchars as word end.

Reproduce code:
---------------
  $pattern = '\bas\b';
  $string = 'D?as';
  echo $string.'<br/>';
  echo mb_ereg_replace($pattern,  '', $string);


Expected result:
----------------
D?as
D?as


Actual result:
--------------
D?as
D?


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-13 19:32 UTC] felipe@php.net
I can reproduce it only in 5.2.
 [2009-12-13 20:32 UTC] manfred at mabuweb dot com
I've no 5.3 version to try, but I just tried in 5.2.11 and can reproduce the error.
 [2009-12-13 20:32 UTC] jani@php.net
I can't:

# php -v
PHP 5.2.12RC2-dev (cli) (built: Nov 22 2009 02:36:43)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
# php t.php
D?as
D?as


 [2009-12-13 20:34 UTC] jani@php.net
Exactly what encodings are you using? (check phpinfo() for mbstring.*)

# php -i |grep mbstring\\.
mbstring.detect_order => no value => no value
mbstring.encoding_translation => Off => Off
mbstring.func_overload => 7 => 7
mbstring.http_input => pass => pass
mbstring.http_output => pass => pass
mbstring.internal_encoding => UTF-8 => UTF-8
mbstring.language => neutral => neutral
mbstring.strict_detection => Off => Off
mbstring.substitute_character => no value => no value

 [2009-12-13 21:49 UTC] manfred at mabuweb dot com
Good question!

php -i |grep mbstring
mbstring.detect_order => no value => no value
mbstring.encoding_translation => Off => Off
mbstring.func_overload => 0 => 0
mbstring.http_input => pass => pass
mbstring.http_output => pass => pass
mbstring.internal_encoding => ISO-8859-1 => no value
mbstring.language => neutral => neutral
mbstring.substitute_character => no value => no value

If I change to UTF-8 everything seems to work as expected:
ini_set('mbstring.internal_encoding', 'UTF-8');
 [2009-12-13 22:15 UTC] jani@php.net
Exactly..
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC