|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-06-26 13:37 UTC] Arne dot Heizmann at csr dot com
Description:
------------
The following example code demonstrates that preg_match_all() does not always return all elements as it should.
Almost any change to the input string makes the bug no longer trigger. For example, remove one of the B's, and the bug no longer occurs. Same goes for the regexp: if you change the (?=X|Y) to (?=X) or anything simpler, the bug no longer triggers.
Reproduce code:
---------------
<?
header ('Content-type: text/plain');
$input = 'A, BBBBBBBB abcd abcd\'y';
preg_match_all ("/[AB]+(?:\\s*\\w+)*(?=X|Y)|./si", $input, $output);
var_export ($output);
?>
Expected result:
----------------
array (
0 =>
array (
0 => 'A',
1 => ',',
2 => ' ',
3 => 'B',
4 => 'B',
5 => 'B',
6 => 'B',
7 => 'B',
8 => 'B',
9 => 'B',
10 => 'B',
11 => ' ',
12 => 'a',
13 => 'b',
14 => 'c',
15 => 'd',
16 => ' ',
17 => 'a',
18 => 'b',
19 => 'c',
20 => 'd',
21 => '\'',
22 => 'y',
),
)
Actual result:
--------------
array (
0 =>
array (
0 => 'A',
1 => ',',
2 => ' ',
),
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 16:00:01 2025 UTC |
backtrack limit reached. use the following: ini_set('pcre.backtrack_limit', PHP_INT_MAX);