#38599 [Opn->Bgs]: Subpattern is not captured for backreference in some cases
| From: | tony2001@php.net | Date: | Mon, 28 Aug 2006 06:15:37 +0000 |
| Subject: | #38599 [Opn->Bgs]: Subpattern is not captured for backreference in some cases | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-101404@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: Bogus
Bug Type: PCRE related
Operating System: All
PHP Version: 4.4.4
New Comment:
PCRE problems and limitations are not PHP problems.
Previous Comments:
------------------------------------------------------------------------
[2006-08-25 23:17:32] pilotv at rambler dot ru
Sorry, I can not compile PHP myself here.
But I tryed latest available for download version 5.1.6. This bug is
still present in it.
------------------------------------------------------------------------
[2006-08-25 21:38:51] tony2001@php.net
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
------------------------------------------------------------------------
[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