#38599 [Opn->Fbk]: Subpattern is not captured for backreference in some cases
| From: | tony2001@php.net | Date: | Fri, 25 Aug 2006 21:38:51 +0000 |
| Subject: | #38599 [Opn->Fbk]: Subpattern is not captured for backreference in some cases | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-101353@lists.php.net to get a copy of this message | ||
ID: 38599
Updated by: tony2001@php.net
Reported By: pilotv at rambler dot ru
-Status: Open
+Status: Feedback
Bug Type: PCRE related
Operating System: All
PHP Version: 4.4.4
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.2-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2006-08-25 21:02:59] pilotv at rambler dot ru
Description:
------------
(Sorry for my english)
Subpattern is not captured for backreference if it is followed by '?'
and does not appear in subject string.
Reproduce code:
---------------
<?
$str=<<<EOD
<a href="aaa">
<a href='aaa'>
<a href=aaa>
EOD;
// Following RE works properly
$re='/<a href=(["\']?)(\w+)\1>/iS';
preg_match_all($re,$str,$regs,PREG_SET_ORDER);
print_r($regs);
// Following RE works wrong
$re='/<a href=(["\'])?(\w+)\1>/iS';
preg_match_all($re,$str,$regs,PREG_SET_ORDER);
print_r($regs);
?>
Expected result:
----------------
// Produced by 1st RE:
Array
(
[0] => Array
(
[0] => <a href="aaa">
[1] => "
[2] => aaa
)
[1] => Array
(
[0] => <a href='aaa'>
[1] => '
[2] => aaa
)
[2] => Array
(
[0] => <a href=aaa>
[1] =>
[2] => aaa
)
)
Actual result:
--------------
// Produced by 2nd RE:
Array
(
[0] => Array
(
[0] => <a href="aaa">
[1] => "
[2] => aaa
)
[1] => Array
(
[0] => <a href='aaa'>
[1] => '
[2] => aaa
)
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38599&edit=1