1//split into array of strings.
2var str = "Well, how, are , we , doing, today";
3var res = str.split(",");
1var myString = 'no,u';
2var MyArray = myString.split(',');//splits the text up in chunks
3
1// bad example https://stackoverflow.com/questions/6484670/how-do-i-split-a-string-into-an-array-of-characters/38901550#38901550
2
3var arr = foo.split('');
4console.log(arr); // ["s", "o", "m", "e", "s", "t", "r", "i", "n", "g"]
1var str = "12,15,16,78,59";
2var res = str.split(",");
3console.log(res[0]); // result: 12
4console.log(res[2]); // result: 16
1const str = 'The quick brown fox jumps over the lazy dog.';
2
3const words = str.split(' ');
4console.log(words[3]);
5// expected output: "fox"
6
7const chars = str.split('');
8console.log(chars[8]);
9// expected output: "k"
10
11const strCopy = str.split();
12console.log(strCopy);
13// expected output: Array ["The quick brown fox jumps over the lazy dog."]
14
1 String[] result = "this is a test".split("\\s");
2 for (int x=0; x<result.length; x++)
3 System.out.println(result[x]);
4