I need to add rel="nofollow"
to all external links (not leading to my site or its subdomains).
I have done this in two steps, at first I add rel="nofollow"
to all links (even internal links) using the following regular expression:
<a href="http([s]?)://(.*?)"
Then in the second step I eliminate rel="nofollow"
for internal links (my site and its subdomains) using the following regular expression:
<a href="http([s]?)://(www\.|forum\.|blog\.)mysite.com(.*?)" rel="nofollow"
How can I do this only in one step? Is it possible?