FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » How do I do this search and replace?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: How do I do this search and replace? [message #172369 is a reply to message #172345] Mon, 14 February 2011 12:58 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 2/13/2011 9:25 PM, Denis McMahon wrote:
> On 14/02/11 01:58, Doug Miller wrote:
>
>> That's outside the original specifications of the problem. Whether the
>> specifications *should* have included that condition is a separate issue. The
>> fact is, they didn't, and the solution Richard posted is a correct solution to
>> to problem as originally posed.
>
> Oh indeed, I only mentioned them because I felt that the OP ought to
> consider the possibility that a system that can generate "\n" and "\r\n"
> as line delimiters might also generate "\r", and possibly various other
> combinations of "\r" and "\n".
>
> replace any combination of one or more carriage returns and line feeds
> with a single cr/lf pair:
>
> $contents = preg_replace("/[\r\n]+/","\r\n",$contents);
>
> Rgds
>
> Denis McMahon

That also will replace things like \r\n\r\n or \n\n with a single \r\n.

Richard's answer is better - it solves the stated problem correctly.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Curious problem
Next Topic: Hot Sameera Hot Cleavage show - Download
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 08:47:25 GMT 2024

Total time taken to generate the page: 0.04575 seconds