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 に答える