Javascript: Convert textarea into an array
This should work (tested in Firefox and Google Chrome): var arrayOfLines = $(‘#textAreaID’).val().split(‘\n’);
This should work (tested in Firefox and Google Chrome): var arrayOfLines = $(‘#textAreaID’).val().split(‘\n’);
I’m one of the SourceTree developers (I develop the Mac version of the product, actually), so hopefully I can be of some help. Windows machines convert CRLF to LF when committing and LF to CRLF when checking out. autocrlf makes sure everything is LF within the repository. The option text = auto is the one … Read more
Regex with replaceAll. public class Main { public static void main(final String[] argv) { String str; str = “hello\r\njava\r\nbook”; str = str.replaceAll(“(\\r|\\n)”, “”); System.out.println(str); } } If you only want to remove \r\n when they are pairs (the above code removes either \r or \n) do this instead: str = str.replaceAll(“\\r\\n”, “”);
There should be a program called dos2unix that will fix line endings for you. If it’s not already on your Linux box, it should be available via the package manager.
Warning: This solution no longer works for Visual Studio 2017 and later. Instead, both of the answers by jcox and Munther Jaber are needed. I have combined them into one answer. As OP states “File > Advanced Save Options”, select Unix Line Endings. This will only affect new files that are created. Fixing any that … Read more