I think you can best match the domain and the path separately, and then merge them back together. Perhaps something like this:
(href=")(http://google\.com)?(/)?(.*)(")
Now you check every match, and put them back together if they are empty. [2] is the domain, [3] the slash, [4] the path. If the domain is always the same you could use a preg_replace.
echo preg_replace('%(href=")(http://google\.com)?(/)?(.*)(")%', 'href="http://google.com/$4"', $yourstring);
pritaeas
Posting Expert
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
pritaeas
Posting Expert
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875