end-of-line

Javascript: Convert textarea into an array

江枫思渺然 提交于 2019-11-26 18:13:20
问题 How would you go about breaking up a textarea value into an array, based on the end of line separation? Use of jQuery is cool by me... 回答1: This should work (tested in Firefox and Google Chrome): var arrayOfLines = $('#textAreaID').val().split('\n'); 回答2: var stringArray = document.getElementById('textarea').value.split('\n'); 回答3: Cross-platform way: var area = document.getElementById("area"); var lines = area.value.replace(/\r\n/g,"\n").split("\n"); 回答4: You could try this function :

How to convert Windows end of line in Unix end of line (CR/LF to LF)

∥☆過路亽.° 提交于 2019-11-26 11:59:37
问题 I\'m a Java developer and I\'m using Ubuntu to develop. The project was created in Windows with Eclipse and it\'s using the CP1252 encoding. To convert to UTF-8 I\'ve used the recode program: find Web -iname \\*.java | xargs recode CP1252...UTF-8 this command gives this error: recode: Web/src/br/cits/projeto/geral/presentation/GravacaoMessageHelper.java failed: Ambiguous output in step `CR-LF..data I\'ve serached about it and get the solution here: http://fvue.nl/wiki/Bash_and_Windows#Recode:

Remove end of line characters from Java string

Deadly 提交于 2019-11-26 08:09:15
问题 I have string like this \"hello java book\" I want remove \\r and \\n from string(hello\\r\\njava\\r\\nbook). I want a string as \"hellojavabook\". How can I do this? 回答1: 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