note 50397 added to function.preg-replace
| From: | php at ihid dot co dot uk | Date: | Sun, 27 Feb 2005 03:42:29 +0000 |
| Subject: | note 50397 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-85619@lists.php.net to get a copy of this message | ||
In the function :
$xml = preg_replace("asd", "\$1".$text."\$2", $xml);
if text starts or finished with a number you will have unexpected behaviour.
If $text = "3asd" for instance, the function will be
$xml = preg_replace("asd", "\$13asd\$2", $xml);
Rather than trying to parse $1 like we want, it will try to use $13, giving a very different result.
Confused me for ages.
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50397
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50397&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50397&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50397&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50397&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50397&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50397&report=yes
Search -- http://master.php.net/manage/user-notes.php