note 85416 deleted from function.preg-replace by crell

From: Date: Fri, 01 Jul 2022 19:46:00 +0000
Subject: note 85416 deleted from function.preg-replace by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218851@lists.php.net to get a copy of this message
Note Submitter: dyer85 at gmail dot com ---- 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.

« previous php.notes (#218851) next »