ID: 49198
Updated by: [email protected]
Reported By: inf3rno dot hu at gmail dot com
Status: Open
Bug Type: PCRE related
-Operating System: Windows XP
+Operating System: *
PHP Version: 5.2.10
New Comment:
Not windows specific
Previous Comments:
------------------------------------------------------------------------
[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