php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48589 /\Q$z\E/ matches every string
Submitted: 2009-06-17 20:23 UTC Modified: 2009-06-17 23:04 UTC
From: mjs at beebo dot org Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.9 OS: OS X
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: mjs at beebo dot org
New email:
PHP Version: OS:

 

 [2009-06-17 20:23 UTC] mjs at beebo dot org
Description:
------------
The regular expression /\Q$z\E/ matches (as far as I can tell) every 
string.  It certainly matches some strings it shouldn't match:

preg_match("/\Q$z\E/", "") -> MATCH (WRONG!)
preg_match("/\Q$z\E/", "qqqq") -> MATCH (WRONG!)

preg_match("/\Q $z\E/", "qqqq") -> NO MATCH (CORRECT)
preg_match("/\Q $z\E/", " $z") -> MATCH (CORRECT)
preg_match("/\Q\$z\E/", "\$z") -> MATCH (CORRECT)
preg_match("/\Q\$z\E/", "$z") -> NO MATCH (CORRECT)

The problem seems to occur if the regular expression begins with the 
string "\Q$" followed by at least one character.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-17 20:45 UTC] mjs at beebo dot org
Regexp documentation:

http://php.net/manual/en/regexp.reference.php
 [2009-06-17 22:58 UTC] felipe@php.net
No bug there, the '$z' enclosed by double quotes is interpreted as a variable first.

http://docs.php.net/manual/en/language.types.string.php
 [2009-06-17 23:04 UTC] mjs at beebo dot org
Ah yes of course, apologies.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 09:01:28 2025 UTC