php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66703 RegexIterator's ALL_MATCH does not filter
Submitted: 2014-02-12 20:49 UTC Modified: 2014-12-28 20:42 UTC
From: jthijssen+php at noxlogic dot nl Assigned: kalle (profile)
Status: Closed Package: SPL related
PHP Version: master-Git-2014-02-12 (Git) OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jthijssen+php at noxlogic dot nl
New email:
PHP Version: OS:

 

 [2014-02-12 20:49 UTC] 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
                )

        )

)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-21 22:48 UTC] cmbecker69 at gmx dot de
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.
 [2014-12-28 20:42 UTC] kalle@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: kalle
 [2014-12-28 20:42 UTC] kalle@php.net
Marking this as fixed as per comment by cmbecker69 at gmx dot de, I'm not able to reproduce it either on my local php-master (7-dev) build.

Please re-open if the issue continues to exists.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 21:01:28 2024 UTC