Um, at a glance it appears to be working for me:
$re='/(<a\/?)(.*)(href?=)("|)(.*)(")(.*)([^>]?>)/ei';
$page = 'Foobar <a href="http://www.google.com/"> wibble';
preg_match($re, $addr, $m);
$page=preg_replace ($re,"'\\1....\\8'",$page);
print_r($m);
echo $page;
But I see other problems - such as the fact that you ought to be using urlencode() rather than str_replace; f? I take to be a typo for f ?; most importantly, it looks as though you allow the attribute value to be quoted with " or nothing, but then you required the attribute value to be ended with ". I suspect however that fixing that may cause more problems.
I've given a regexp for matching the href attribute of an <a> tag a couple of times before. Rather than repeat the post, I'll give a link here.