ID:               49198
 Comment by:       inf3rno dot hu at gmail dot com
 Reported By:      inf3rno dot hu at gmail dot com
 Status:           Open
 Bug Type:         PCRE related
 Operating System: *
 PHP Version:      5.2.10
 New Comment:

It's not preg_match_all specific, same bug with every preg function.


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

[2009-08-08 21:04:32] paj...@php.net

Not windows specific

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

[2009-08-08 20:08:15] inf3rno dot hu at gmail dot com

Description:
------------
For pattern: .* there is an empty match at the end of the string.

Reproduce code:
---------------
$p1='/.*/';
$p2='/.*$/';
$p3='/^.*/';
$p4='/^.*$/';
$test='some text';

function test($p,$t)
{
        preg_match_all($p,$t,$m,PREG_SET_ORDER);
        echo $p.'<br />';
        if (count($m)==1)
                echo '<div style="color: green;">ok</div>';
        else
                echo '<div style="color: red;">bug</div>';
        echo '<pre>'.var_export($m,true).'</pre>';
        echo '<br /><br />';
}

test($p1,$test);
test($p2,$test);
test($p3,$test);
test($p4,$test);

Expected result:
----------------
I'm expecting one match in the preg_match_all result array, and I will
get two instead of one. The second match is empty.

Actual result:
--------------
/.*/
bug

array (
  0 => 
  array (
    0 => 'some text',
  ),
  1 => 
  array (
    0 => '',
  ),
)



/.*$/
bug

array (
  0 => 
  array (
    0 => 'some text',
  ),
  1 => 
  array (
    0 => '',
  ),
)



/^.*/
ok

array (
  0 => 
  array (
    0 => 'some text',
  ),
)



/^.*$/
ok

array (
  0 => 
  array (
    0 => 'some text',
  ),
)


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


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

Reply via email to