Bug #53797 [Opn->Bgs]: PCRE_DOTALL modifier overrides non-greedy operator

From: Date: Thu, 20 Jan 2011 12:11:19 +0000
Subject: Bug #53797 [Opn->Bgs]: PCRE_DOTALL modifier overrides non-greedy operator
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-158034@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53797&edit=1 ID: 53797 Updated by: felipe@php.net Reported by: lists at excogitate dot co dot uk Summary: PCRE_DOTALL modifier overrides non-greedy operator -Status: Open +Status: Bogus Type: Bug Package: PCRE related Operating System: Windows 7 PHP Version: 5.3.5 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Previous Comments: ------------------------------------------------------------------------ [2011-01-20 02:41:09] lists at excogitate dot co dot uk Description: ------------ If the PCRE_DOTALL 's' modifier is specified in the regex, instances of the non-greedy (lazy) operator '?' are ignored. Test script: --------------- $input = <<<END <p>paragraph 1</p> <p>paragraph 2</p> END; print "Output 1:\n"; print preg_replace('|<p.*?>paragraph 2</p>|', '', $input); print "\nOutput 2:\n"; print preg_replace('|<p.*?>paragraph 2</p>|s', '', $input); Expected result: ---------------- Output 1 and Output 2 should be the same, i.e. with the second paragraph removed. Actual result: -------------- Output 2, with the PCRE_DOTALL modifier set, is blank: the first pattern matched greedily. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53797&edit=1

« previous php.bugs (#158034) next »