• Login
Community
  • Login

Search for inconsistent line endings with a regex?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
4 Posts 2 Posters 2.6k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A
    Alan Kilborn
    last edited by Jan 18, 2017, 4:06 PM

    Is it possible to search for inconsistent line-endings in a file using a regular expression?

    It CAN happen that you get a mix of different line-ending types in a file, and it is usually WRONG when it happens.

    I’d like to detect this, using the line-ending on line 1 as the “gold standard”. Meaning, consider the line-ending on line 1 and if any of lines 2 thru the end of the file have a DIFFERENT line-ending, match it with a regex search.

    I’m not that great with regex, so I don’t know if this is possible or not. I’d appreciate someone either writing the regex for me (if it can be done), or giving me some pointers in the correct direction.

    C 1 Reply Last reply Jan 18, 2017, 4:24 PM Reply Quote 0
    • C
      Claudia Frank @Alan Kilborn
      last edited by Jan 18, 2017, 4:24 PM

      @Alan-Kilborn

      it is not really clear what you try to accomplish?
      Match the whole text, only the EOLs, only the line
      with the wrong EOLS (including/excluding).
      And what do you want to do afterwards?

      If you, for example, just want to change the eols I would
      use menu edit->eol conversion

      Cheers
      Claudia

      A 1 Reply Last reply Jan 18, 2017, 6:01 PM Reply Quote 0
      • A
        Alan Kilborn @Claudia Frank
        last edited by Jan 18, 2017, 6:01 PM

        @Claudia-Frank

        Hi Claudia,
        I would like to bookmark the lines with line-endings different than that of the first line of the file. I know how to bookmark with the Mark feature, but I just need a regex to feed it…

        C 1 Reply Last reply Jan 19, 2017, 12:46 AM Reply Quote 0
        • C
          Claudia Frank @Alan Kilborn
          last edited by Jan 19, 2017, 12:46 AM

          @Alan-Kilborn

          Hi Alan,

          currently I only have a solution for each eol.

          (?-s).*$(?!\r\n)   (lines not ending in win eol format \r\n)
          (?-s).*$(?!\n)   (lines not ending in unix eol format \n)
          (?-s).*$(?=\n|\r\n)   (lines not ending in old mac eol format \r)
          

          Cheers
          Claudia

          1 Reply Last reply Reply Quote 0
          1 out of 4
          • First post
            1/4
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors