note 54461 added to function.preg-replace
| From: | crosser at hanmail dot net | Date: | Tue, 05 Jul 2005 09:26:21 +0000 |
| Subject: | note 54461 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-91463@lists.php.net to get a copy of this message | ||
\ (back slash) pattern & replacement bug.
// \a\b\c to -\a-\b-\c
$subject = '\\a\\b\\c';
$pattern = '/\\\[a-z]/'; // why \\\ ?
$replacement = '-\0';
echo preg_replace($pattern, $replacement, $subject);
// abc to \a\b\c
$subject = 'abc';
$pattern = '/[a-z]/';
$replacement = '\\\\\0'; // why \\\\ ?
echo preg_replace($pattern, $replacement, $subject);
I use pattern \x5c and replacement callback function...
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54461
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54461&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54461&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54461&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54461&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54461&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54461&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54461&report=yes
Search -- http://master.php.net/manage/user-notes.php