|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53797 PCRE_DOTALL modifier overrides non-greedy operator
Submitted: 2011-01-20 02:41 UTC Modified: 2011-01-20 13:11 UTC
From: lists at excogitate dot co dot uk Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.3.5 OS: Windows 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: lists at excogitate dot co dot uk
New email:
PHP Version: OS:


 [2011-01-20 02:41 UTC] lists at excogitate dot co dot uk
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>


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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-20 13:11 UTC]
-Status: Open +Status: Bogus
 [2011-01-20 13:11 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun May 22 08:05:44 2022 UTC