Search for inconsistent line endings with a regex?
-
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.
-
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 conversionCheers
Claudia -
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… -
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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login