php.net |  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
 [2009-05-12 23:46 UTC] steve42lawson at gmail dot com
Description:
------------
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 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

\w = alphanumeric and _


 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed May 18 09:04:05 2022 UTC