[SalesForce] How to split a string by the newline character in Apex

I wonder if it's possible to use the apex public String[] split(String regExp) method to split a string by the newline characters. The string being a csv file created on the Windows platform.

I tried several apex expressions in different forms and shapes, but it either doesn't work for me or it probably leaves the carriage return symbol within the resulting strings (if I try to match a resulting string against another clean string it should match, they don't match).

Best Answer

Try \n:

myInput.split('\n');

If your input uses \r\n, that is another common option.

myInput.split('\r\n');