#48589 [Opn]: /\Q$z\E/ matches every string

From: Date: Wed, 17 Jun 2009 20:45:20 +0000
Subject: #48589 [Opn]: /\Q$z\E/ matches every string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-138426@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: Open Bug Type: PCRE related Operating System: OS X PHP Version: 5.2.9 New Comment: Regexp documentation: http://php.net/manual/en/regexp.reference.php Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#138426) next »