|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81296 A question about square bracket matching
Submitted: 2021-07-26 03:32 UTC Modified: 2021-07-26 03:37 UTC
From: 958268052 at qq dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 8.0.8 OS: Ubuntu18.04
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: 958268052 at qq dot com
New email:
PHP Version: OS:


 [2021-07-26 03:32 UTC] 958268052 at qq dot com
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:
function matchTest($reg,$str){
    if (empty($r)) {
        return "";
    return $r[0];
$regex = "/[£]/";
$testString = "£";
$result = matchTest($regex, $testString);

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-26 03:37 UTC]
-Status: Open +Status: Not a bug -Package: *Regular Expressions +Package: PCRE related
 [2021-07-26 03:37 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

Use the /u flag to turn on UTF-8 support.
 [2021-07-26 14:19 UTC] 958268052 at qq dot com
I've understood what the problem is, thanks for your prompt answer and help!
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Jan 24 21:03:34 2022 UTC