#38599 [Fbk->Opn]: Subpattern is not captured for backreference in some cases
| From: | pilotv at rambler dot ru | Date: | Fri, 25 Aug 2006 23:17:32 +0000 |
| Subject: | #38599 [Fbk->Opn]: Subpattern is not captured for backreference in some cases | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-101355@lists.php.net to get a copy of this message | ||
ID: 38599
User updated by: pilotv at rambler dot ru
Reported By: pilotv at rambler dot ru
-Status: Feedback
+Status: Open
Bug Type: PCRE related
Operating System: All
PHP Version: 4.4.4
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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