Home Download Buy Blog Forum Support

Regex: Carriage Return not found

Regex: Carriage Return not found

Postby Randy_sublime on Wed Nov 21, 2012 8:43 pm

There is a recurring need to find windows carriage return characters and the regex "\r" never matches a thing in my sublime text 2. Newline "\n" always works.
I have checked the binary codes with Total Commander and it shows 0D 0A patterns in text where line breaks show up in windows notepad. And sublime
finds the newlines as \n OR binary x0A. It never finds any of the carriage returns as \r OR as the binary equivalent 0D, even though they are there for certain.

I have a need to find the carriage returns distinctly from other line break characters.

Can someone, anyone, try to match \r AND \x0D in there sublime text in a file they know contains such characters?
For windows, those files are easy to make. Notepad. Enter key makes carriage return + newline = 0D 0A = \r\n

Thank you anyone :)
Randy_sublime
 
Posts: 2
Joined: Mon Jul 09, 2012 2:26 am

Re: Regex: Carriage Return not found

Postby bizoo on Wed Nov 21, 2012 9:03 pm

I pretty sure that buffer never contains "\r", only "\n".
When ST2 read a file, line endings are normalized to "\n" and ST2 remember what it was before (Windows, linux or Mac)
When the file is write back to disk, "\n" are replaced by the corresponding line endings.

If you have a file with mixed line endings, ST2 will probably normalize them (and you have a problem).
bizoo
 
Posts: 859
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Regex: Carriage Return not found

Postby Randy_sublime on Wed Nov 21, 2012 11:10 pm

Hey thanks bizoo. What I have experienced can all be explained by what you have said. I am satisfied with that and will not have to have an unpleasant puzzle in my head.

ST2 will probably normalize them (and you have a problem)


Ya, for sure. And that's another problem solved. I have many times saved a file in ST2 that looks good with normal lines breaks. Upon opening the file next time, surprise - every second line is blank! Yes, a problem. Yes, a mess!

Many thanks amigo :).
Randy_sublime
 
Posts: 2
Joined: Mon Jul 09, 2012 2:26 am


Return to Technical Support

Who is online

Users browsing this forum: Yahoo [Bot] and 9 guests