RegEx matching help

Ok, this one has got me stumped.

I’ve got the following html code:

[code]

[/code]

I’m trying to parse out some data from it. Using this php code it works:

[php]
preg_match_all(’|<tr.+[^>]>.[^<]<th.+[^<]</a>.(?P<class_name>.). - (?P<class_stats>Total Entries: (?P<total_entries>\d+) .Trophies:.(?P\d+)[^<])</th>|’,$res,$classes,PREG_SET_ORDER);
[/php]

returns:

Array
(
    [0] => Array
        (
            [0] => <tr class=rowlow>
<th nowrap rowspan="1" colspan="5" align="left"><a name="p"></a>'Pro' - Total Entries: 10  Trophies: 4</th>
            [class] => p
            [1] => p
            [class_name] => Pro
            [2] => Pro
            [class_stats] => Total Entries: 10  Trophies: 4
            [3] => Total Entries: 10  Trophies: 4
            [total_entries] => 10
            [4] => 10
            [trophies] => 4
            [5] => 4
        )

)

But I want it to match all the way to the end because there is more data past here that I want to parse.

I try adding .*</tr> to the end of my regex and it breaks it:

[php]
preg_match_all(’|<tr.+[^>]>.[^<]<th.+[^<]</a>.(?P<class_name>.). - (?P<class_stats>Total Entries: (?P<total_entries>\d+) .Trophies:.(?P\d+)[^<])</th>.*</tr>|’,$res,$classes,PREG_SET_ORDER);
[/php]

Returns nothing… I just don’t understand why… should the .* not encompass everything until the first ? I’ve of course tried variations using .[^<]</tr> .+[^<]*</tr> .+</tr> none seem to work.

Can anyone help?

'Pro' - Total Entries: 10 Trophies: 4 Sponsor Times Total

Update,
Just wanted to update that I don’t need an answer to this anymore.

I never figured it out, got so aggrivated with it and switched to using the Dom document to parse through the HTML instead.

If anyone would like to answer it though I would still be interested in knowing the correct way to acheive what I was trying to do for future reference.

Sponsor our Newsletter | Privacy Policy | Terms of Service