php.net |  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
37 - 30 = ?
Subscribe to this entry?

 
 [2011-01-20 02:41 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-20 13:11 UTC] felipe@php.net
-Status: Open +Status: Bogus
 [2011-01-20 13:11 UTC] felipe@php.net
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


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 15:01:29 2024 UTC