Bug #81296 [Opn->Nab]: A question about square bracket matching
| From: | requinix@php.net | Date: | Mon, 26 Jul 2021 03:37:35 +0000 |
| Subject: | Bug #81296 [Opn->Nab]: A question about square bracket matching | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-235348@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81296&edit=1
ID: 81296
Updated by: requinix@php.net
Reported by: 958268052 at qq dot com
Summary: A question about square bracket matching
-Status: Open
+Status: Not a bug
Type: Bug
-Package: *Regular Expressions
+Package: PCRE related
Operating System: Ubuntu18.04
PHP Version: 8.0.8
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Use the /u flag to turn on UTF-8 support.
https://www.php.net/manual/en/reference.pcre.pattern.modifiers.php
Previous Comments:
------------------------------------------------------------------------
[2021-07-26 03:32:08] 958268052 at qq dot com
Description:
------------
I executed this test script below, redirecting the result to a file, and I got an execution result
of "Ã".
When I execute it on other regular expression engines like java and python using the same regular
expression and string, they both result in "ã", unlike PHP. I don't understand
why PHP has such a different result, is this a special implementation of the PHP regular expression
engine or a defect in the engine?
Test script:
---------------
<?php
function matchTest($reg,$str){
preg_match($reg,$str,$r);
if (empty($r)) {
return "";
}
else{
return $r[0];
}
}
$regex = "/[£]/";
$testString = "£";
$result = matchTest($regex, $testString);
print_r($result);
?>
Expected result:
----------------
ã
Actual result:
--------------
Ã
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81296&edit=1