Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #18675
    Jamil
    Participant

    I had a need to search for the number of carriage returns that exist in a text file. This is a carriage return only and not CR+LF combination. I opened up the text file in EmEditor version 14.5.3, opened up the find dialog, checked off:

    Use Regular Expressions
    Move to Start/End of Document
    Count Matches

    For search criteria, I entered: \r

    When I click either find next or find all, I get really unusual results. It stated that 8,984 matches were found. This number is incorrect, since there are roughly 134 carriage return characters in the file.

    Is it possible to fix this?

    Thanks.

    #18676
    Stefan
    Participant

    \r is right, basically.
    But for EE us rather \n, no matter if for CR or CRLF

    See help
    EmEditor Home – EmEditor Help – How to – Search
    To Specify New Lines

    An good indicator are also the line numbers (View > Line Numbers)
    and also View > Marks > Returns
    and View > Marks > CR and LF with different Marks

    .

    #18678
    Jamil
    Participant

    In regular expressions, a carriage return is indicated by \r. \n is a newline character. This is standard everywhere. So, this is by design?

    The C++ standard library implements regular expressions correctly, so in the worst case scenario, I could look into creating a plugin that does it.

    #18679
    Yutaka Emura
    Keymaster

    Hello Jamil,

    To correctly find CR only lines, please use Find in Files (not normal Find), click the “>” button next to the File Types, and select “Current File”.

    Then check Use Regular Expressions, and find:

    \r(?!\n)

    This will find all files with CR only.

    I hope this helps.

    Thank you!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.