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

From: Date: Mon, 26 Jul 2021 03:32:08 +0000
Subject: Bug #81296 [NEW]: A question about square bracket matching
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235347@lists.php.net to get a copy of this message
From: 958268052 at qq dot com Operating system: Ubuntu18.04 PHP version: 8.0.8 Package: *Regular Expressions Bug Type: Bug Bug description:A question about square bracket matching 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 bug report at https://bugs.php.net/bug.php?id=81296&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81296&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81296&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81296&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81296&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81296&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81296&r=support Expected behavior: https://bugs.php.net/fix.php?id=81296&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81296&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81296&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81296&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81296&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81296&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81296&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81296&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81296&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81296&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81296&r=mysqlcfg

« previous php.bugs (#235347) next »