使用preg_replace删除不需要的链接


Using preg_replace to remove unwanted links

我正试图删除这样的东西:

<a href="http://women.domain.com">women.domain.com</a>

我想应该是:

$this->tresc[$i][description]=preg_replace("/'<a(.*)href=('"|')http:'/'/women'.domain'.com.*('"|')(.*)'/'>/i", "",$this->tresc[$i][description]);

但它不起作用。

对于图像,我使用这个,它工作得很好:

$this->tresc[$i][description]=preg_replace("/'<img(.*)src=('"|')http:'/'/women'.domain'.com.*('"|')(.*)'/'>/i", "",$this->tresc[$i][description]);
$pattern = '('<a href=["|'']+[http(s)?:'/'/]+([a-z0-9'-]+[.]){1,}+[a-z]{2,4}+['/]+(.*)+["|'']'>+(.*)+'</a'>)';
$string = "click <a href='http://subdomain.sitename.tld/somedir'>here</a>";
var_dump(preg_replace($pattern, "", $string)); // prints "string 'click ' (length=6)"
$this->tresc[$i][description]=preg_replace("/'<a .*'>.*'<'/a'>/i", "", $this->tresc[$i][description]);
$this->tresc[$i][description]=preg_replace("/<a href='"(.*)'">/i", "",$this->tresc[$i][description]);
$this->tresc[$i][description]=preg_replace("/<'/a'>/i", "",$this->tresc[$i][description]);