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.
    • Alan KilbornA
      Alan Kilborn
      last edited by

      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.

      Claudia FrankC 1 Reply Last reply Reply Quote 0
      • Claudia FrankC
        Claudia Frank @Alan Kilborn
        last edited by

        @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

        Alan KilbornA 1 Reply Last reply Reply Quote 0
        • Alan KilbornA
          Alan Kilborn @Claudia Frank
          last edited by

          @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…

          Claudia FrankC 1 Reply Last reply Reply Quote 0
          • Claudia FrankC
            Claudia Frank @Alan Kilborn
            last edited by

            @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
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors