If I were to use preg_replace
, what would be the corresponding regex in order to determine whether or not a string contains one or more <a>
tags, and then add rel="nofollow"
to it?
So it would take this:
Hi! What's up? <a href="http://test.com">Click here</a> to check out
<a href="http://apple.com">my</a> website. This is <b>also</b> a test.
And turn it into this:
Hi! What's up? <a href="http://test.com" rel="nofollow">Click here</a>
to check out <a href="http://apple.com" rel="nofollow">my</a> website. This is
<b>also</b> a test.