Req #67520 [Opn->Nab]: preg_match should capture always all parentheses
| From: | ab@php.net | Date: | Tue, 01 Jul 2014 06:55:45 +0000 |
| Subject: | Req #67520 [Opn->Nab]: preg_match should capture always all parentheses | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-186404@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67520&edit=1
ID: 67520
Updated by: ab@php.net
Reported by: hejdav at centrum dot cz
Summary: preg_match should capture always all parentheses
-Status: Open
+Status: Not a bug
Type: Feature/Change Request
Package: *Regular Expressions
Operating System: Windows 7
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
preg_match_all() is probably what can fulfill your expectation.
Previous Comments:
------------------------------------------------------------------------
[2014-06-26 07:03:41] hejdav at centrum dot cz
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 this bug report at https://bugs.php.net/bug.php?id=67520&edit=1