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

JQuery Autocomplete without using label, value, id -

c++ - Accessing inactive union member and undefined behavior? -

JAVA - what is the difference between void and boolean methods? -