You are here: Re: [PHP] Re: newline and pregreplace « PHP « IT news, forums, messages
Re: [PHP] Re: newline and pregreplace

Posted by Dotan Cohen on 06/25/05 03:42

On 6/25/05, Bob Winter <b2winter@yahoo.com> wrote:
>
>
> Bob Winter wrote:
> > Dotan Cohen wrote:
> >
> >> I'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 Lyrics
> >
> >
> > Dotan,
> >
> > Try escaping the newline in your example:
> > $str=preg_replace( "-regex here-", '\\n<note>\1</note>', $str);
> >
> > --Bob
> Dotan,
>
> 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.
>
> --Bob
>

I actually discovered that there are places that I DONT want the
newline- so I'm just going to leave the notes on the same line for
now. But thanks for that tip conserning the dollar sign- I know that I
will need that in the future.

Dotan
http://lyricslist.com/lyrics/artist_albums/19/adams_bryan.php
Bryan Adams Song Lyrics

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация