I'm using this code to replace urls in a string
preg_replace('#<a.*?>(.*?)</a>#i', '\1', $text)
How do I do the same thing, but keeping urls that match a certain pattern (ie start with a domain I want to keep)?
Update
Turns out that the urls I want to keep include relative urls, so I now want to eliminate all urls that don't match the given url pattern and are not relative links.