[pmwiki-devel] changing \n to other delimiter
Patrick R. Michaud
pmichaud at pobox.com
Tue May 15 18:31:41 CDT 2007
On Tue, May 15, 2007 at 06:16:28PM -0400, The Editor wrote:
> On 5/15/07, Christophe David <pmwiki at christophedavid.org> wrote:
> > > $out = str_replace("\n", "||", $in);
> > > $out = preg_replace('/\\n/', "||", $in);
> > >
> > > Both seem to do the replacement, but don't get rid of the line break...
> >
> >
> > Depending on your OS, you can have \r (MAC), \n (Unix) or \r\n (Windows) as
> > end of line delimiters.
> >
> > This should work everywhere : $out = preg_replace('/[\\n\\r]/', "||", $in);
>
> Thanks again Christophe! Just what I needed to know. I ended up
> having to slightly modify the pattern...
>
> '/[\\n\\r]{1,2}/'
Note that this will convert a pair of newlines into a single '||' .
I'm guessing that you'll want
'/\\r\\n?|\\n/'
Pm
More information about the pmwiki-devel
mailing list