split (RegExp - JavaScript)

Splits a string between string separators.

Defined in

RegExp (Standard - JavaScript)

Syntax

split(separator:string, limit:int) : string[]
Parameters Description
separator The string to be split.
limit A limit on the number of splits.
Return value Description
string[] Substrings resulting from the splits.

Usage

This RegExp object is the separator. A null or empty separator splits the string between every character.

Examples

This example displays Paris,Moscow,Tokyo.
var cities = new String("Paris;   Moscow;  Tokyo");
var re = new RegExp("\\s*;\\s*");
re.split(cities, 16).toString()