Req #67520 [NEW]: preg_match should capture always all parentheses

From: Date: Thu, 26 Jun 2014 07:03:42 +0000
Subject: Req #67520 [NEW]: preg_match should capture always all parentheses
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186347@lists.php.net to get a copy of this message
From: hejdav at centrum dot cz Operating system: Windows 7 PHP version: Irrelevant Package: *Regular Expressions Bug Type: Feature/Change Request Bug description:preg_match should capture always all parentheses Description: ------------ When preg_match() is called, I'm expecting that $matches will contain always one index per one capturing group. But when there is capturing group at the end of the pattern and it is not matched, $matches does not contain its index. Test script: --------------- $regexp = '/foo( bar)?/'; preg_match($regexp, 'foo', $matches); print_r($matches); Expected result: ---------------- Array ( [0] => foo [1] => ) Actual result: -------------- Array ( [0] => foo ) -- Edit bug report at https://bugs.php.net/bug.php?id=67520&edit=1 --

« previous php.bugs (#186347) next »