note 79758 deleted from function.preg-replace by googleguy

From: Date: Tue, 22 Oct 2013 08:01:10 +0000
Subject: note 79758 deleted from function.preg-replace by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196728@lists.php.net to get a copy of this message
Note Submitter: admin[a-t]saltwaterc[d0t]net ---- <?php function repl_amp($text) { $text=preg_replace("/&(?!amp;)/i", "&", $text); $text=preg_replace("/&#(\d+);/i", "&#$1;", $text); // For numeric entities $text=preg_replace("/&(\w+);/i", "&$1;", $text); // For literal entities return $text; } ?> The RegEx Tester says that the first expression is OK, but when testing with various entities, some of them came out broken. I'd tried to use only 2 preg_replace(); calls instead of three by using the alternative branch from the pattern syntax - which didn't came out well. Sorry for the previous error, and I still hope that someone can find a better alternative.

« previous php.notes (#196728) next »