note 87300 deleted from function.preg-replace by crell

From: Date: Fri, 01 Jul 2022 19:38:34 +0000
Subject: note 87300 deleted from function.preg-replace by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218843@lists.php.net to get a copy of this message
Note Submitter: mdrisser at gmail dot com ---- An alternative to the method suggested by sheri is to remember that the regex modifier '$' only looks at the end of the STRING, the example given is a single string consisting of multiple lines. Try: <?php // Following is 1 string containing 3 lines $s = "Testing, testing.\r\n" . "Another testing line.\r\n" . "Testing almost done."; echo preg_replace('/\.\\r\\n/m', '@\r\n', $s); ?> This results in the string: Testing, testing@\r\nAnother testing line@\r\nTesting almost done.

« previous php.notes (#218843) next »