Bug #53956 [Bgs]: Zero Width Space is not replaced by ordinary space
| From: | rasmus@php.net | Date: | Tue, 08 Feb 2011 21:12:18 +0000 |
| Subject: | Bug #53956 [Bgs]: Zero Width Space is not replaced by ordinary space | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-158611@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53956&edit=1
ID: 53956
Updated by: rasmus@php.net
Reported by: skyboy at mail dot ru
Summary: Zero Width Space is not replaced by ordinary space
Status: Bogus
Type: Bug
Package: PCRE related
Operating System: Ubuntu 10.10
PHP Version: 5.3.5
Block user comment: N
Private report: N
New Comment:
You should ask the PCRE guys about that.
Previous Comments:
------------------------------------------------------------------------
[2011-02-08 21:40:18] skyboy at mail dot ru
oh!sorry for this. this is my mistake.
but why "zero width *space*" does not belong to [s]pace symbols' group?
------------------------------------------------------------------------
[2011-02-08 11:15:39] aharvey@php.net
Your arguments to preg_replace are swapped, ie:
preg_replace('#\s+#', $str, '-');
should be:
preg_replace('#\s+#', '-', $str);
Also note that Unicode zero width spaces aren't included in \s, but
you can match them directly with the u modifier (replace <200b> with
an actual zero width space character):
preg_replace('#<200b>+#u', '-', $str);
Not a bug: closing.
------------------------------------------------------------------------
[2011-02-08 10:45:51] skyboy at mail dot ru
Description:
------------
Group of zero width spaces is succesfully replaced by any character but
ordinary space.
Test script:
---------------
$str = "âââââââââ"; // 27 zero width spaces
with
unicode code of u200B
var_dump($str);
var_dump(preg_replace('#\s+#', $str, '-'));
var_dump(preg_replace('#\s+#', $str, ' '));
Expected result:
----------------
string(27) "âââââââââ" string(1)
"-" string(1)
"âââââââââ-"
Actual result:
--------------
string(27) "âââââââââ" string(1)
"-" string(27)
"âââââââââ"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53956&edit=1