Bug #81296 [Com]: A question about square bracket matching

From: Date: Mon, 26 Jul 2021 14:19:37 +0000
Subject: Bug #81296 [Com]: A question about square bracket matching
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235368@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 Comment by: 958268052 at qq dot com Reported by: 958268052 at qq dot com Summary: A question about square bracket matching Status: Not a bug Type: Bug Package: PCRE related Operating System: Ubuntu18.04 PHP Version: 8.0.8 Block user comment: N Private report: N New Comment: I've understood what the problem is, thanks for your prompt answer and help! Previous Comments: ------------------------------------------------------------------------ [2021-07-26 03:37:35] requinix@php.net 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 ------------------------------------------------------------------------ [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

« previous php.bugs (#235368) next »