php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73573 Сase-insensitive search error
Submitted: 2016-11-21 10:32 UTC Modified: 2016-11-21 11:03 UTC
From: ruk at mgpu dot ru Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 7.0.13 OS: Windows Server 2012 R2
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: ruk at mgpu dot ru
New email:
PHP Version: OS:

 

 [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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-21 11:03 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Package: *Regular Expressions +Package: PCRE related
 [2016-11-21 11:03 UTC] requinix@php.net
(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
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 04:01:29 2024 UTC