brotherhood_of_LAN - 2:50 pm on Jul 3, 2011 (gmt 0)
Using regex to match HTML can get messy. Using PHP's DOM [php.net] functions might be easier. I found them a bit awkward to get to grips with but they bypass a lot of hassle in trying to parse documents.
$dom = new DOMDocument;
// echo Links and their anchor text
foreach($dom->getElementsByTagName('a') as $link)
$href = $link->getAttribute('href');
$anchor = $link->nodeValue;
// Do something here