Bug #66703 [Com]: RegexIterator's ALL_MATCH does not filter

From: Date: Fri, 21 Nov 2014 22:48:55 +0000
Subject: Bug #66703 [Com]: RegexIterator's ALL_MATCH does not filter
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188740@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66703&edit=1 ID: 66703 Comment by: cmbecker69 at gmx dot de Reported by: jthijssen+php at noxlogic dot nl Summary: RegexIterator's ALL_MATCH does not filter Status: Open Type: Bug Package: SPL related PHP Version: master-Git-2014-02-12 (Git) Block user comment: N Private report: N New Comment: Apparently, this issue has recently been fixed for PHP 5.5.19 and 5.6.3, see <http://3v4l.org/SkLsJ>. That might have been a side effect of fixing <https://bugs.php.net/bug.php?id=68128>. BTW: the expected and actual results given above are mixed up. Previous Comments: ------------------------------------------------------------------------ [2014-02-12 20:49:06] jthijssen+php at noxlogic dot nl Description: ------------ When filtering with the RegexIterator and using the ALL_MATCH mode, every element is returned, even if it does not have any matches. This functionality differs from the GET_MATCH, which does filter out empty/non-matching elements Test script: --------------- $it = new \ArrayIterator(array("tmp", "foo", "bar", "bazbar")); $it = new \RegexIterator($it, "/ba(.)/", \RegexIterator::ALL_MATCHES); print_r(iterator_to_array($it)); Expected result: ---------------- Array ( [0] => Array ( [0] => Array ( ) [1] => Array ( ) ) [1] => Array ( [0] => Array ( ) [1] => Array ( ) ) [2] => Array ( [0] => Array ( [0] => bar ) [1] => Array ( [0] => r ) ) [3] => Array ( [0] => Array ( [0] => baz [1] => bar ) [1] => Array ( [0] => z [1] => r ) ) ) Actual result: -------------- Array ( [2] => Array ( [0] => Array ( [0] => bar ) [1] => Array ( [0] => r ) ) [3] => Array ( [0] => Array ( [0] => baz [1] => bar ) [1] => Array ( [0] => z [1] => r ) ) ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66703&edit=1

« previous php.bugs (#188740) next »