| nlopess@php.net 2006-06-26, 7:58 am |
| ID: 37913
Updated by: nlopess@php.net
Reported By: tom at foreignproperty dot com
-Status: Open
+Status: Bogus
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:
No. The example is correct. It shows how to use nested parenteses and
backreferences.
Previous Comments:
------------------------------------------------------------------------
[2006-06-26 09:30:28] tom at foreignproperty dot com
look at the array keys.
it goes $matches[0], $matches[1], then jumps to $matches[3] and
$matches[4]
Shouldn't part 2 be matches[2], and part 3 be $matches[3]?
------------------------------------------------------------------------
[2006-06-26 08:40:08] takagi@php.net
No, that's perfectly correct.
The regx is "/(<([\w]+)[^>]*> )(.*)(<\/\\2> )/".
So,
[1] correspond to (<([\w]+)[^>]*> ),
[2] correspond to ([\w]+),
[3] correspond to (.*), and
[4] correspond to (<\/\\2> ).
------------------------------------------------------------------------
[2006-06-26 08:16:06] tom at foreignproperty dot com
Description:
------------
In the description for preg_match_all, in the 2nd example, Find
matching HTML tags (greedy), the part 2 and part 3 array values are
wrong ($matches[3], $matches[4]).
echo "matched: " . $matches[0][$i] . "\n";
echo "part 1: " . $matches[1][$i] . "\n";[color=darkred]
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37913&edit=1
|