#45366 [Opn->Ver]: preg_match_all() misses elements (corner-case)

From: Date: Wed, 02 Jul 2008 02:48:52 +0000
Subject: #45366 [Opn->Ver]: preg_match_all() misses elements (corner-case)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-126172@lists.php.net to get a copy of this message
ID: 45366 Updated by: felipe@php.net Reported By: Arne dot Heizmann at csr dot com -Status: Open +Status: Verified Bug Type: PCRE related Operating System: * PHP Version: 5.2.6 New Comment: I can reproduce. PS: The example works fine on pcretest (PCRE version 7.6). Previous Comments: ------------------------------------------------------------------------ [2008-06-26 13:37:36] 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 => ' ', ), ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45366&edit=1

« previous php.bugs (#126172) next »