(( <a href="http://)?(">http://)?(</a> [\w\-/\.]+)+\s) is a much simpler regular expression and does the same thing. Match 1 is your link so you can pretty much just replace your regex with that and replace \\0 with \\1.
However it can't really be fixed by a one-liner.
$link = preg_replace('#((http://)?([\w\-/\.]+)+\s)#', '\1', $r->text);
$link = (strpos($link, 'http://') === false)) ? $link = 'http://'.$link : $link;
$link = "<a href='$link' title='$link' rel='nofollow'>$link</a>';
That gives you the fully prepared link.
ShawnCplus
Code Monkey
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268