2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by pritaeas
0

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);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.