Regular expression

$string='
<a href="http://www.DOMAINa.com" target="_blank">1</a>
<a title="b" href="http://DOMAINa.com" target="_blank">2</a>
<a title="c" href="http://DOMAINa.com/test#a">3</a>
<a href="http://www.DOMAINb.com" target="_blank">4</a>
';

$pattern = '/<a[^>]+>(.*)<\\/a>/i';
$output = preg_replace($pattern, '', $str);

// should echo
// 1
// 2
// 3
// <a href="http://www.DOMAINb.com" target="_blank">4</a>

Need to remove all links from DOMAINa.com

Could you please help with the expression?

$string=' 
<a href="http://www.DOMAINa.com" target="_blank">1</a> 
<a title="b" href="http://DOMAINa.com" target="_blank">2</a> 
<a title="c" href="http://DOMAINa.com/test#a">3</a> 
<a href="http://www.DOMAINb.com" target="_blank">4</a> 
'; 

$pattern = '/<a(.*?)DOMAINa.com(.*?)>(.*?)<\\/a>/i'; 
$output = preg_replace($pattern, '{hiddenlink}', $string);
echo $output; 

gives:

{hiddenlink} 
{hiddenlink} 
{hiddenlink} 
<a href="http://www.DOMAINb.com" target="_blank">4</a> 

If you want to show 1,2,3,4 etc replace {hiddenlink} with $2 in Gar onn’s code :slight_smile: