|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-03-09 11:59 UTC] mmcnickle at gmail dot com
[2009-03-09 12:16 UTC] sehh at ionos dot gr
[2009-03-09 14:31 UTC] mmcnickle at gmail dot com
[2009-03-09 14:54 UTC] sehh at ionos dot gr
[2009-03-09 15:00 UTC] sehh at ionos dot gr
[2009-03-09 15:25 UTC] mmcnickle at gmail dot com
[2009-03-09 16:01 UTC] sehh at ionos dot gr
[2009-03-09 17:20 UTC] mmcnickle at gmail dot com
[2009-03-12 09:39 UTC] sehh at ionos dot gr
[2009-03-12 18:46 UTC] nlopess@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 17 06:00:01 2025 UTC |
Description: ------------ preg_replace with the "/i" (case insensitive search) does not do a case insensitive search for UTF-8 Greek characters, while it works fine for English characters. Reproduce code: --------------- <?php $string = "?? ?????? ????? ??? ????????, ???? ??? ???????????? ???? ??????????"; // UTF-8 string in Greek language $target1 = "????????"; // Target string to search for (capitalized) $target2 = "????????"; // Target string to search for (small letters) $replace = "itworks"; // Replace with this string $rc = preg_replace("/$target1/imsUu", $replace, $string, -1, $counter); // Execute search for target1 and replace echo "\nSearching for: ".$target1."\n"; // Report output echo "Result string: ".$rc."\n"; echo "Found and replaced: ".$counter."\n"; $rc = preg_replace("/$target2/imsUu", $replace, $string, -1, $counter); // Execute search for target2 and replace echo "\nSearching for: ".$target2."\n"; // Report output echo "Result string: ".$rc."\n"; echo "Found and replaced: ".$counter."\n\n"; ?> Expected result: ---------------- I expect the Found and Replaced to be both "1" since the expression is not case sensitive. Actual result: -------------- $ php -f test.php Searching for: ???????? Result string: ?? ?????? ????? ??? ????????, ???? ??? ???????????? ???? ?????????? Found and replaced: 0 Searching for: ???????? Result string: ?? ?????? ????? ??? itworks, ???? ??? ???????????? ???? ?????????? Found and replaced: 1