#48589 [Bgs]: /\Q$z\E/ matches every string
| From: | mjs at beebo dot org | Date: | Wed, 17 Jun 2009 23:04:48 +0000 |
| Subject: | #48589 [Bgs]: /\Q$z\E/ matches every string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-138432@lists.php.net to get a copy of this message | ||
ID: 48589
User updated by: mjs at beebo dot org
Reported By: mjs at beebo dot org
Status: Bogus
Bug Type: PCRE related
Operating System: OS X
PHP Version: 5.2.9
New Comment:
Ah yes of course, apologies.
Previous Comments:
------------------------------------------------------------------------
[2009-06-17 22:58:31] 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 20:45:19] mjs at beebo dot org
Regexp documentation:
http://php.net/manual/en/regexp.reference.php
------------------------------------------------------------------------
[2009-06-17 20:23:44] 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.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48589&edit=1