Bug #13559 Updated: parser misinterprets ?> in a regexp

From: Date: Tue, 09 Oct 2001 20:59:54 +0000
Subject: Bug #13559 Updated: parser misinterprets ?> in a regexp
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-67637@lists.php.net to get a copy of this message
ID: 13559 Updated by: jeroen Reported By: cech@debian.org Status: Bogus Bug Type: PCRE related Operating System: Debian PHP Version: 4.0.6 New Comment: And $article = preg_replace("/<([^>]*)(\s+[^>]*)?>/xs", goes perfectly right, as it should. KISS example: $myvar = "ab?>cd"; should work (and does work). Inside strings everything is allowed, when you place // before the line, that string protection obviously doesn't work anymore. Previous Comments: ------------------------------------------------------------------------ [2001-10-09 14:47:13] sander@php.net Intended behaviour. From the docs (http://www.php.net/manual/en/language.basic-syntax.comments.php): "The 'one-line' comment styles actually only comment to the end of the line or the current block of PHP code, whichever comes first." ------------------------------------------------------------------------ [2001-10-05 05:50:43] cech@debian.org From Debian bug #114345 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=114345&repeatmerged=yes When presented with a perfectly valid regular expression that contains ?> in it, these characters are confused with those used to close a block of php code in the html file. Example: // $article = preg_replace("/<([^>]*)(\s+[^>]*)?>/s", // '', // $article); Even though this entire block is commented out, I still get a parse error due to the ?> in the regexp. The workaround seems to be use of the x modifier, and putting whitespace between the ? and >, like so... $article = preg_replace("/<([^>]*)(\s+[^>]*)? >/xs", Mike ---------- P.S. cannot there be a mail reportin interface? ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=13559&edit=1

« previous php.dev (#67637) next »