|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-01-23 18:00 UTC] keith at chaos-realm dot net
Description:
------------
When using the following test script to strip out all unicode except for letters the string becomes garbled when the * qualifier is added, the only surviving character that is intact is ú.
Also, if you add \pN to the exceptions it additionally preserves the ó.
Verified on 5.2,5.3 and 5.3-SNAP.
Test script:
---------------
echo preg_replace('/[^\pL\pM]*/iu', '', 'áéíóú');
or
echo preg_replace('/[^\pL\pM\pN]*/iu', '', 'áéíóú');
Expected result:
----------------
áéíóú
Actual result:
--------------
����ú
or
���óú (if \pN is added to the exceptions).
Patchesbug53823.phpt (last revision 2012-02-25 09:53 UTC by robertbasic dot com at gmail dot com)Pull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 06:00:01 2025 UTC |
A workaround is to use + instead of *. These work as expected: echo preg_replace('/[^\pL\pM]*/iu', '', 'áéíóú'); echo preg_replace('/[^\pL\pM\pN]*/iu', '', 'áéíóú');...and then I forget to change the *. Let's try that again... These work as expected: echo preg_replace('/[^\pL\pM]+/iu', '', 'áéíóú'); echo preg_replace('/[^\pL\pM\pN]+/iu', '', 'áéíóú');