Click to Rate and Give Feedback
Collapse All/Expand All Collapse All
This page is specific to
.NET Framework 3.0

Other versions are also available for the following:
 Collapse AllExpand All        Code: All Code: Multiple Code: Visual Basic Code: C# Code: Visual C++ Code: JScript 
split Method (Windows Scripting - JScript)

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

stringObj.split([separator[, limit]])
stringObj

Required. The String object or literal to be split. This object is not modified by the split method.

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.

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

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 ss = s.split(" ");
   return(ss);
}
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
consecutive delimiters are merged (no null strings returned)      ttulinsky   |   Edit   |   Show History
consecutive delimiters are merged (no null strings returned) e.g.

var s = "aaaNbbbRcccRNdddNReeeR";
sar = s.split(/N|R/);

produces:

string '0' = aaa
string '1' = bbb
string '2' = ccc
string '3' = ddd
string '4' = eee
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker