85
rated 0 times
[
86]
[
1]
/ answers: 1 / hits: 115088
/ 14 Years ago, thu, february 17, 2011, 12:00:00
How do you split a long piece of text into separate lines? Why does this return line1 twice?
/^(.*?)$/mg.exec('line1rnline2rn');
[line1, line1]
I turned on the multi-line modifier to make ^
and $
match beginning and end of lines. I also turned on the global modifier to capture all lines.
I wish to use a regex split and not String.split
because I'll be dealing with both Linux n
and Windows rn
line endings.
More From » regex