例如,<a href="http://msdn.microsoft.com/art029nr/">remove links to here but keep text</a> but <a href="http://herpyderp.com">leave all other links alone</a>
PHP刪除鏈接到特定的網站,但保留文本
我一直在試圖解決這個使用的preg_replace。我在這裏搜索並找到解決問題的答案。
PHP: Remove all hyperlinks of specific domain from text的答案刪除指向特定網址的鏈接,但也刪除文本。
http://php-opensource-help.blogspot.ie/2010/10/how-to-remove-hyperlink-from-string.html的網站從字符串中刪除超鏈接,但我似乎無法修改該模式,因此它只適用於特定的網站。
[不要使用正則表達式解析HTML](http://stackoverflow.com/a/1732454/344643)使用[XML解析器](http://us2.php.net/manual/en/class。 domdocument.php)代替。 – 2013-02-11 00:13:02