#45916 [Bgs]: PCRE_DOTALL with PCRE_UNGREEDY not skip the end newline character

From: Date: Wed, 27 Aug 2008 03:24:13 +0000
Subject: #45916 [Bgs]: PCRE_DOTALL with PCRE_UNGREEDY not skip the end newline character
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-128461@lists.php.net to get a copy of this message
 ID:               45916
 User updated by:  xxorax at gmail dot com
 Reported By:      xxorax at gmail dot com
 Status:           Bogus
 Bug Type:         PCRE related
 Operating System: win32
 PHP Version:      5.2.6
 New Comment:

oups ! all is right with PCRE_DOLLAR_ENDONLY option, a différence with
perl.

thanks ! and sorry for trouble.


Previous Comments:
------------------------------------------------------------------------

[2008-08-27 00:22:59] 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 00:18:08] xxorax at gmail dot com

this is same result...

------------------------------------------------------------------------

[2008-08-26 22:14:09] jani@php.net

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi



------------------------------------------------------------------------

[2008-08-26 02:56:56] 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:
--------------
""
---
"
"
---
"
"
---



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=45916&edit=1



Thread (5 messages)

« previous php.bugs (#128461) next »