Hi all,

I am having an issue, where a freelancer uploaded some files to our server, and we run Apache FTP and it adds CR and LFs to the line endings and we get double and tripled spaced files.

I checked Apache FTP (running on Windows 2003 Server) and there does not seem to be a transfer setting (unix vs. windows).

And I tried with our FTP app both binary and ASCII and it did not make a difference.

Long story short, I need to edit the files and remove the extra line breaks.

I tried 'code beautifier' in PHP edit and it does not address line breaks.

I also used a regular expression in dreamweaver [\r\n]{2,} changed to \n and it finds a lot and says it replaced them, but only for the first pass, then nothing.

I opened a file in Programmers Notepad and it shows:

// text CRLF
---CR <-- NOTE: the --- indicate what looks like line spaces between the CRLF and CR
CRLF
---CR
CRLF
// more text

So I tried [\r\n\r]{2,} and got nothing also.

I am hoping someone has solved this already.

Thanks in advance,
Don

    dmacman1962 wrote:

    I checked Apache FTP (running on Windows 2003 Server) and there does not seem to be a transfer setting (unix vs. windows).

    Do the files on the Windows server use CRLF linebreaks?

    The FTP protocol defaults to ASCII with CRLF linebreaks (it's an old protocol - long story) - so any ASCII transfer will use CRLF linebreaks. A binary transfer will not change the byte stream, so if the original had CRLF, so would the copy.

    Could you just replace "\r" with "" to turn CRLF into LF?

    Or maybe the freelancer really did upload files like that 🙂

      Do the files on the Windows server use CRLF linebreaks?

      It looks like it does use CRLF for line breaks.

      And I remember from the 'ole days' the EOL ASCII 'schtuff' from my dial up days in the 80's.

      I dug up this article about it, which I believe is what you where referring to in ...

      (it's an old protocol - long story)

      I tried the \r search (in dreamweaver) with regular expression on and it finds nothing after the first pass (which removes a bunch of them).

      I see in Programmers Notepad that there is now a "CRLF" followed by 2 spaces repeating 3 times, now which is causing the extra line breaks.

      I did not find a "\" {space} character so I could do another regex on it like I did with \r\n. Can you tell me the 'space' equivalent for this and I will add it to my regex search and see what happens?

      Thanks,
      Don

        I figured it out.

        [\r\n\s\s]{2,}

        [duh!]

        Did the trick!

        Thanks, Weedpacket.

        PS: Do you know of anyone looking for a 'slightly used' ENIAC? Pickup only, no delivery. lol

        regards,
        Don

          Write a Reply...