There you go
$patterns="/pubmed\/2562222/";
$replacements="http://www.ncbi.nlm.nih.gov/pubmed/2562222";
$string = '<a href="https://stackoverflow.com/questions/16963490/pubmed/2562222"></a>';
print( preg_replace($patterns, $replacements, $string));
This will output
<a href="http://www.ncbi.nlm.nih.gov/pubmed/2562222"></a>
Live Demo
3
solved change URL in from anchor tag using preg_replace [closed]