See also: splitString |
Splits a string into pieces delimited by the characters in a string and then creates an array with those pieces.
JSV_parseString(expS, delimiters [, keepDelimiters])
expS.parseString(delimiters [, keepDelimiters])
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.
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. |
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.
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
Copyright © 1998-2000 Roaring Fork Software. All rights reserved.