See also: splitString

Splits a string into pieces delimited by the characters in a string and then creates an array with those pieces.

Syntax

JSV_parseString(expS, delimiters [, keepDelimiters])

Prototype

expS.parseString(delimiters [, keepDelimiters])

Returns

Returns an array of elements from a expS. If the delimiters does not exist in the string, the string is returned in the element of a one-dimensional array. If the optional argument keepDelimiters is used, then the delimiters are included in the returned array.

Parameters

The parseString function uses the following arguments.

Argument Description
expS String being searched.
delimiters String consisting of delimiters used in string.
keepDelimiters Optional. Boolean value that indicates whether the returned array will also contain the delimiters. Default value is true.

Remarks

Unlike splitString, parseString separates the delimited list using more than one delimiter and provides the capability for the programmer to retain the delimiters in the resulting array.

Dependencies

JSV_isEmpty

Example

The following lines of code

var i = 0;
var delimitedString = "red,white,blue";
document.write( "The delimited string " +
    delimitedString.bold() + 
    " contains the following elements:" );
var dsElements = JSV_parseString(delimitedString, ",");
for (i=0; i<dsElements.length; i++) {
    document.write( "Element " + i + " is " + dsElements[i].bold() );
}

produce