php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45916 PCRE_DOTALL with PCRE_UNGREEDY not skip the end newline character
Submitted: 2008-08-26 02:56 UTC Modified: 2008-08-27 03:24 UTC
From: xxorax at gmail dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.6 OS: win32
Private report: No CVE-ID: None
 [2008-08-26 02:56 UTC] 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:
--------------
""
---
"
"
---
"
"
---


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-27 00:18 UTC] xxorax at gmail dot com
this is same result...
 [2008-08-27 00:22 UTC] felipe@php.net
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.
 [2008-08-27 03:24 UTC] xxorax at gmail dot com
oups ! all is right with PCRE_DOLLAR_ENDONLY option, a diff?rence with perl.

thanks ! and sorry for trouble.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 01:01:30 2024 UTC