Codice PHP:
$stringa preg_replace("/\\'(\\<br\\>|\\\&nbsp\\;)\\'/e""htmlentities('\\\\1')"$stringa);