[pmwiki-devel] changing \n to other delimiter
Patrick R. Michaud
pmichaud at pobox.com
Wed May 16 06:55:40 CDT 2007
On Wed, May 16, 2007 at 06:53:17AM +0200, Christophe David wrote:
> > 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}/'
>
> This is still not perfect, as two consecutive "blank" lines will be
> converted once.
>
> '/([\\r\\n]|\\r|\\n)/' is probably better.
This pattern doesn't catch CR+NL (\r\n) sequences. :-)
Pm
More information about the pmwiki-devel
mailing list