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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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
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

Pull Requests

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: Sun Dec 22 01:01:30 2024 UTC