I want to split 2 or more new lines in JavaScript.
For example,
Hello
\n
Don't split me
\n
\n
But split me since I am 2 or more lines below
\n
\n
\n
\n
\n
\n
You can also split me since I am 6 lines below
should result in
1
Hello
Don't split me
2
But split me since I am 2 or more lines below
3
You can also split me since I am 6 lines below
Basically removing all \n
.
I tried doing str.split(/\r?\n/)
but it splits for single-line. I want it to do for 2 or more lines but it must work for CR, LF, and CRLF line endings.
I did see https://stackoverflow.com/a/52947649/6141587 but it only does for single-line as well. Literally, every answer is for a single-line break which I know how to do.
I want it to work for 2 or more new lines.
How do I do it?