Entry
How can I split a string?
Mar 3rd, 2000 20:33
Martin Honnen,
Strings have a split method that takes a separator string or even a
separator regular expressions as the argument and returns an array of
substrings resulting from splits where the separator is found.
So for instance
var s = 'Kibology for all'
alert(s.split(' '))
splits the string s into the three words.
Or
var s =
'Kibology for all.\r\nAll for Kibology.\nScriptology for all.';
alert(s.split(/\r\n|\r|\n/));
splits the string into the lines.