Hi all,
Can anyone help me out in putting together an expression which will run through the document and replace all cases of the ampersand sign with the ampersand html entity leaving out those ampersands which already belong to an html entity
Thanks
preg_replace pattern to html entities ampersands
Moderator: General Moderators
Re: preg_replace pattern to html entities ampersands
Over at http://www.addedbytes.com/html/on-the-fly-validation/, I found this one which seems to do the trick:
$output = preg_replace("/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w{1,8});)/i", "&", $output);
Any comments?
$output = preg_replace("/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w{1,8});)/i", "&", $output);
Any comments?