js split string to array
JavaScript[Edit]
+
0
-
0
js split string to array
1 2 3 4var text = 'This is some text...'; var array = text.split(' '); // space character separator used console.log(array); // ['This','is','some','text...']
[Edit]
+
0
-
0
js split string to array
1 2 3 4var text = 'This is some text...'; var array = text.split('is'); // this character sequence separates string console.log(array); // ['Th',' ',' some text...']
[Edit]
+
0
-
0
js split string to array
1 2 3 4var text = 'This is some text...'; var array = text.split(''); // empty separator used console.log(array); // ['T','h','i','s',' ','i','s',' ','s','o','m','e',' ','t','e','x','t','.','.','.']
[Edit]
+
0
-
0
js split string to array
1 2 3 4var text = 'This is some text...'; var array = text.split(' ', 2); // maximum result array size will be 2 console.log(array); // ['This','is']
[Edit]
+
0
-
0
js split string to array
1 2 3 4var text = 'This is some text...'; var array = text.split(/\b/); // begin or end of word separates string console.log(array); // ['This',' ','is',' ','some',' ','text','...']
[Edit]
+
0
-
0
js split string to array
1 2 3 4var text = 'This is some text...'; var array = text.split(/\b/, 2); // maximum result array size will be 2 console.log(array); // ['This',' ']