Share via


split Method

Returns the array of strings that results when a string is separated into substrings.

function split([ separator : { String | RegExp } [, limit : Number]]) : Array

Arguments

  • separator
    Optional. A string or an instance of a Regular Expression object identifying one or more characters to use in separating the string. If omitted, a single-element array containing the entire string is returned.

  • limit
    Optional. A value used to limit the number of elements returned in the array.

Remarks

The result of the split method is an array of strings split at each point where separator occurs in the string. The separator is not returned as part of any array element.

Example

The following example illustrates the use of the split method.

function SplitDemo(){
    var s = "The quick brown fox jumps over the lazy dog.";
    // Split at each space character.
    var arr = s.split(" ");
    return(arr);
}

Requirements

Version 3

Applies To:

String Object

See Also

Reference

concat Method (String)

RegExp Object

Regular Expression Object

Concepts

Regular Expression Syntax