LS,I'm using the following code to add \[code\]<span>\[/code\] tags behind \[code\]<a>\[/code\] tags.\[code\]$html = preg_replace("~<a.*?href=http://stackoverflow.com/questions/2022158//"$url\".*?>.*?</a>~i", "$0<span>test</span>", $html);\[/code\]The code is working fine for regular links (ie. http://www.google.com/), but it will not perform a replace when the contents of $url are \[code\]$link$/3/\[/code\].This is example code to show the (mis)behaviour:\[code\]<?php $urls = array(); $urls[] = '$link$/3/'; $urls[] = 'http://www.google.com/'; $html = '<a href="http://stackoverflow.com/questions/2022158/$link/3/">Test Link</a>' . "\n" . '<a href="http://www.google.com/">Google</a>'; foreach($urls as $url) { $html = preg_replace("~<a.*?href=http://stackoverflow.com/questions/2022158//"$url\".*?>.*?</a>~i", "$0<span>test</span>", $html); } echo $html;?>\[/code\]And this is the output it produces:\[code\]<a href="http://stackoverflow.com/questions/2022158/$link$/3/">Test Link</a><a href="http://www.google.com/">Google</a><span>test</span>\[/code\]Kind regards,Matthias Vance