S > String.split |  |

String.split

string, string.split, split

Availability

Flash Player 5.

Usage

    myString.split("delimiter", [limit])

Parameters

`delimiter` The character or string at which `myString` splits. If the `delimiter` parameter is undefined, the entire string is placed in the first element of the array.

`limit` The number of items to place into the array. This parameter is optional.

Returns

An array containing the substrings of `myString`.

Description

Method; splits a String object into substrings by breaking it wherever the specified `delimiter` parameter occurs, and returns the substrings in an array. If you use an empty string ("") as a delimiter, each character in the string is placed as an element in the array, as in the following code.

    myString = "Joe";
    i = myString.split("");
    trace (i);

The Output window displays the following:

    J, O, E

If the `delimiter` parameter is undefined, the entire string is placed into the first element of the returned array.

Example

The following example returns an array with five elements.

    myString = "P, A, T, S, Y";
    myString.split(",");

This example returns an array with two elements.

    myString.split(",", 2);