note 87300 added to function.preg-replace
| From: | mdrisser at gmail dot com | Date: | Fri, 28 Nov 2008 18:13:55 +0000 |
| Subject: | note 87300 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-147095@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 208.69.120.35
Probable Submitter: 192.104.231.235
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- https://master.php.net/note/edit/87300
Del: integrated -- https://master.php.net/note/delete/87300/integrated
Del: useless -- https://master.php.net/note/delete/87300/useless
Del: bad code -- https://master.php.net/note/delete/87300/bad+code
Del: spam -- https://master.php.net/note/delete/87300/spam
Del: non-english -- https://master.php.net/note/delete/87300/non-english
Del: in docs -- https://master.php.net/note/delete/87300/in+docs
Del: other reasons-- https://master.php.net/note/delete/87300
Reject -- https://master.php.net/note/reject/87300
Search -- https://master.php.net/manage/user-notes.php