Use Javascript to select a line of Text
-
OK, so.
NotePad++ is showing CR LF, as the document end of line.
This matches \r\n ( \r = Carriage Return, \n = Line Feed )reference: https://en.wikipedia.org/wiki/...
So: txt.split("\r\n") should match that every end of line (but splitting on this will not remove any trailing sets from doubles)
Now if you want to split the text only one DOUBLE breaks... you are looking at CR LF CR LFSo try: txt.split("\r\n\r\n")
-
@dusx thank you! I guess I just switched \r with \n bevor. And now I know what's happening in the different cases and why ("\n\r") is doing the Job kind as well.
In between (.../) shows the match of regex and therefore the position of the split:
("\r\n\r\n") =
Line one text 'CR LF'
line two text (CR LF
CR LF/)
third line of text
("\r\n") =
Line one text (CR LF/)
line two text (CR LF/)
(CR LF/)
third line of text("\n\r") =
Line one text 'CR LF'
line two text 'CR' (LF
CR/) 'LF'
third line of text