0

我正在尝试删除这样的内容:

<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]);
4

3 回答 3

0
$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)"
于 2012-07-07T12:00:17.073 回答
-1
$this->tresc[$i][description]=preg_replace("/\<a .*\>.*\<\/a\>/i", "", $this->tresc[$i][description]);
于 2012-07-07T11:39:11.747 回答
-1
$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]);
于 2012-07-10T18:03:48.507 回答