I’m confused with what is the correct way to break lines.
I read somewhere that windows use \r\n to break lines, but this two codes produce the same
regex.split(sometext, "\r\n");
regex.split(sometext, "\n");
What it is the correct way?, these expressions always produce the same?
If you want to support new-line characters for every platform (e.g. you need to parse input files, created under Linux/Windows/Mac in your ASP.NET web-site) and you do not carry about empty strings, I suggest to use this method instead:
This will return
for input string
Update:
If you need to carry about empty lines, you can use
This should work for both “\r\n” and “\n” EOL charracter files.