Page 1 of 1

preg_match nested capture group order issue.

PostPosted: March 10th, 2016, 1:44 pm
by niallb
Hi,

When the inner of two nested numbered capture groups starts at the same location as the outer one Phalanger is getting the numbering wrong.

e.g.
Code: Select all
        preg_match('/((a)b)/', 'cab', $matches);
        print_r($matches);

With PHP outputs
Code: Select all
Array
(
    [0] => ab
    [1] => ab
    [2] => a
)

however, with Phalanger the output is
Code: Select all
Array
(
    [0] => ab
    [1] => a
    [2] => ab
)


(A work around is to insert a dummy non capturing group,
Code: Select all
 preg_match('/((?:)(a)b)/', 'cab', $matches);
)