|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-11-21 10:32 UTC] ruk at mgpu dot ru
Description:
------------
In line with the processing of the Cyrillic alphabet in the regular expression key /i (case-insensitive search) error occurs
Windows Server 2012 R2
IIS 8.5
PHP 7.0.9 x64
Test script:
---------------
<?php
header('Content-Type: text/plain; charset=windows-1251');
$RegularExpression = '/^[a-zа-я]+$/i';
$TestStrArray = array('ABC', 'abc', 'АБВ', 'абв');
foreach ($TestStrArray as $TestStr)
{
$Result = preg_match($RegularExpression, $TestStr);
echo $TestStr;
if ($Result === false)
{
echo ' - Error'."\r\n";
}
else
{
echo ' - '.($Result === 0 ? 'not found' : 'found')."\r\n";
}
} // foreach
?>
Expected result:
----------------
ABC - found
abc - found
АБВ - not found
абв - found
Actual result:
--------------
ABC - found
abc - found
АБВ - found
абв - found
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 19 08:00:01 2025 UTC |
(Expected and Actual are backwards) To match non-ASCII characters you must use UTF-8 and the /u flag. '/^[a-zа-я]+$/iu' - only if the file is in UTF-8 encoding "/^[a-z\u{0430}-\u{044F}]+$/iu" https://3v4l.org/t4h9t