split (String - JavaScript)
Splits a string between string separators.
Defined in
String (Standard - JavaScript)Syntax
split(separator:string, limit:int) : string[]
Parameters | Description |
---|---|
separator |
The separator. A null or empty separator splits the string between every character. |
limit |
A limit on the number of splits. |
Return value | Description |
---|---|
string[] |
Substrings resulting from the splits. |
Examples
(1) This example displaysParis,Moscow,Tokyo
.var cities = new String("Paris Moscow Tokyo");
cities.split(" ", 5).toString()
(2) This example does
the same.
var cities = new String("Paris; Moscow; Tokyo");
cities.split(/\s*;\s*/, 5).toString()