|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48253 preg_match backslash-w matches digits
Submitted: 2009-05-12 23:46 UTC Modified: 2009-05-12 23:58 UTC
From: steve42lawson at gmail dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.9 OS: Apache/2.0.52 (Red Hat)
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: steve42lawson at gmail dot com
New email:
PHP Version: OS:


 [2009-05-12 23:46 UTC] steve42lawson at gmail dot com
In a pattern parsed by preg_match, the 'backslash-w' meta-character (which is described as matches 'any "word" character') matches digits as well (i.e. [0-9]). This is true inside and outside of square-brackets.

Reproduce code:
$subject = "12345";
$result = preg_match('/\w+/i', $subject);
echo "\w result: $result <br />";
$result = preg_match('/[a-z]+/i', $subject);
echo "[a-z] result: $result <br />";

Expected result:
\w result: 0
[a-z] result: 0 

Actual result:
\w result: 1
[a-z] result: 0 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-12 23:58 UTC]
It's expected.

\w = alphanumeric and _

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun May 22 19:03:48 2022 UTC