note 85416 added to function.preg-replace
| From: | dyer85 at gmail dot com | Date: | Fri, 29 Aug 2008 02:41:49 +0000 |
| Subject: | note 85416 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143965@lists.php.net to get a copy of this message | ||
There seems to be some unexpected behavior when using the /m modifier when the line terminators are
win32 or mac format.
If you have a string like below, and try to replace dots, the regex won't replace correctly:
<?php
$s = "Testing, testing.\r\n"
. "Another testing line.\r\n"
. "Testing almost done.";
echo preg_replace('/\.$/m', '.@', $s); // only last . replaced
?>
The /m modifier doesn't seem to work properly when CRLFs or CRs are used. Make sure to convert
line endings to LFs (*nix format) in your input string.
----
Server IP: 64.71.164.2
Probable Submitter: 96.251.61.40
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- https://master.php.net/note/edit/85416
Del: integrated -- https://master.php.net/note/delete/85416/integrated
Del: useless -- https://master.php.net/note/delete/85416/useless
Del: bad code -- https://master.php.net/note/delete/85416/bad+code
Del: spam -- https://master.php.net/note/delete/85416/spam
Del: non-english -- https://master.php.net/note/delete/85416/non-english
Del: in docs -- https://master.php.net/note/delete/85416/in+docs
Del: other reasons-- https://master.php.net/note/delete/85416
Reject -- https://master.php.net/note/reject/85416
Search -- https://master.php.net/manage/user-notes.php