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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: steve42lawson at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

History

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

\w = alphanumeric and _


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 10:01:29 2025 UTC