preg_match nested capture group order issue.

Phalanger Tools for Visual Studio [?] is complete PHP/Phalanger integration into Visual Studio development environment.

preg_match nested capture group order issue.

Postby niallb » March 10th, 2016, 1:44 pm

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);
)
niallb
 
Posts: 1
Joined: March 10th, 2016, 1:07 pm

Return to Phalanger Tools

Who is online

Users browsing this forum: No registered users and 3 guests

cron

User Control Panel

Login

Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests (based on users active over the past 5 minutes)
Most users ever online was 151 on December 6th, 2020, 7:46 am

Users browsing this forum: No registered users and 3 guests