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
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: xxorax at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 01:01:33 2025 UTC