Re: newline and pregreplace
| From: | Bob Winter | Date: | Sat, 25 Jun 2005 00:34:02 +0000 |
| Subject: | Re: newline and pregreplace | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-217583@lists.php.net to get a copy of this message | ||
Bob Winter wrote:
Dotan Cohen wrote:I'd like to recant my previous post, I made the mistake of not testing my suggestion first . . . try this instead: $str=preg_replace( "-regex here-", "\n<note>$1</note>", $str); If you still have a problem, post the regex you are using and maybe a sample string. --BobI've got a line like this: $str=preg_replace( "-regex here-", '\n<note>\1</note>', $str); Which has one of two problems: If I leave the single quotes around the second argument, then it returns as \n and not a newline. If I change the single quotes to double quotes, then the info from the regex is not inserted in place of the \1. What is one to do in these situations? Dotan http://lyricslist.com/lyrics/artist_albums/273/jackson_michael.php Michael Jachson LyricsDotan, Try escaping the newline in your example: $str=preg_replace( "-regex here-", '\\n<note>\1</note>', $str); --Bob Dotan,