Problem with Regexp

From: Date: Mon, 31 Oct 2005 15:27:50 +0000
Subject: Problem with Regexp
Groups: php.general 
Request: Send a blank email to php-general+get-224879@lists.php.net to get a copy of this message
Hello, I have the string: <tr><td><img src="http://www.runescape.com/img/hiscores/attack.gif" valign="bottom" width=16 height=16 /></td><td>&nbsp;</td><td><a href="hiscoreuser.cgi?username=zezima&category=1" class=c>Attack</a></td><td align="right">4</td><td align="right">99</td><td align="right">53,156,556</td></tr> and I apply preg_match_all: preg_match_all("/(<tr><td><img src=\"http:\/\/www.runescape.com\/img\/hiscores\/attack.gif\" valign=\"bottom\" width=16 height=16 \/><\/td><td>&nbsp;<\/td><td><a href=\"hiscoreuser.cgi\?username=)([\w])+(&category=1\" class=c>Attack<\/a><\/td><td align=\"right\">)([1-9])+(<\/td><td align=\"right\">)([1-9])+(<\/td><td align=\"right\">)([1-9,])+(<\/td><\/tr>)/",$seite,$attack); ($seite is the string) If i make print_r($attack); then I get: Array ( [0] => Array
       (
           [0] => <tr><td><img src="http://www.runescape.com/img/hiscores/attack.gif" valign="bottom" width=16 height=16 /></td><td>&nbsp;</td><td><a href="hiscoreuser.cgi?username=zezima&category=1" class=c>Attack</a></td><td align="right">4</td><td align="right">99</td><td align="right">53,156,556</td></tr>
       )
[1] => Array
       (
           [0] => <tr><td><img src="http://www.runescape.com/img/hiscores/attack.gif" valign="bottom" width=16 height=16 /></td><td>&nbsp;</td><td><a href="hiscoreuser.cgi?username=
       )
[2] => Array
       (
           [0] => a
       )
[3] => Array
       (
           [0] => &category=1" class=c>Attack</a></td><td align="right">
       )
[4] => Array
       (
           [0] => 4
       )
[5] => Array
       (
           [0] => </td><td align="right">
       )
[6] => Array
       (
           [0] => 9
       )
[7] => Array
       (
           [0] => </td><td align="right">
       )
[8] => Array
       (
           [0] => 6
       )
[9] => Array
       (
           [0] => </td></tr>
       )
) But I would expect to get [2] => Array
       (
           [0] => zezima
       )
[6] => Array
       (
           [0] => 99
       )
[8] => Array
       (
           [0] => 53,156,556        )
Instead of the values above. Can you explain me how I can get those values? Yannick Mortier

« previous php.general (#224879) next »