php - Using preg_replace to remove unwanted links -


i'm trying remove this:

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

i thought should be:

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

but doesn't work.

for images use , it's working perfectly:

$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)" 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -