I need to remove <a href
from text, except if domain/url in href contains example.com
I have found this regex, but it replaces right now all urls (.*?)
, any ideas how to make it so it replaces all hrefs except if url contains example.com
preg_replace('/<a href=\"(.*?)\">(.*?)<\/a>/', "\\2", $_POST['desc']);
Here is example how the replace should work
<a href="http://example.com/test">test1</a> ==> Should not be replaced (targeted)
<a href="http://google.com/test">test2</a> ==> test2