#45916 [Opn->Bgs]: PCRE_DOTALL with PCRE_UNGREEDY not skip the end newline character

From: Date: Wed, 27 Aug 2008 00:22:59 +0000
Subject: #45916 [Opn->Bgs]: PCRE_DOTALL with PCRE_UNGREEDY not skip the end newline character
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-128460@lists.php.net to get a copy of this message
ID: 45916 Updated by: felipe@php.net Reported By: xxorax at gmail dot com -Status: Open +Status: Bogus Bug Type: PCRE related Operating System: win32 PHP Version: 5.2.6 New Comment: Hello, that result is expected, read about the 'D' modifier in the documentation: http://docs.php.net/manual/en/reference.pcre.pattern.modifiers.php Thanks. Previous Comments: ------------------------------------------------------------------------ [2008-08-27 00:18:08] xxorax at gmail dot com this is same result... ------------------------------------------------------------------------ [2008-08-26 22:14:09] jani@php.net Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows (zip): http://snaps.php.net/win32/php5.2-win32-latest.zip For Windows (installer): http://snaps.php.net/win32/php5.2-win32-installer-latest.msi ------------------------------------------------------------------------ [2008-08-26 02:56:56] xxorax at gmail dot com Description: ------------ strange bug, this code skip all characters expect the end \n (\r is find). This is the same when .*? is in subpattern. Reproduce code: --------------- $str = "test\ntest\r\n"; function v($s) { echo '"'.$s.'"'."\n---\n"; } echo v(preg_replace('#^.*$#s','', $str)); echo v(preg_replace('#^.*?$#s','', $str)); echo v(preg_replace('#^.*$#Us','', $str)); Expected result: ---------------- "" --- "" --- "" --- Actual result: -------------- "" --- " " --- " " --- ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45916&edit=1

« previous php.bugs (#128460) next »