note 79758 added to function.preg-replace
| From: | admin | Date: | Tue, 11 Dec 2007 16:17:05 +0000 |
| Subject: | note 79758 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-133369@lists.php.net to get a copy of this message | ||
Actually I made a mistake in my previous post. In order to make the function more effective ... I
broke it. The original which works (really) looks like this:
<?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.
----
Server IP: 69.147.83.197
Probable Submitter: 195.137.204.178
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- https://master.php.net/note/edit/79758
Del: integrated -- https://master.php.net/note/delete/79758/integrated
Del: useless -- https://master.php.net/note/delete/79758/useless
Del: bad code -- https://master.php.net/note/delete/79758/bad+code
Del: spam -- https://master.php.net/note/delete/79758/spam
Del: non-english -- https://master.php.net/note/delete/79758/non-english
Del: in docs -- https://master.php.net/note/delete/79758/in+docs
Del: other reasons-- https://master.php.net/note/delete/79758
Reject -- https://master.php.net/note/reject/79758
Search -- https://master.php.net/manage/user-notes.php