Example of using the split function in javascript to split a string: scriptalert (c: wwwccvita.jpg); varpathc: wwwccvita.jpg; vararrpath. split (); alert (arr);/script the following is a detailed description of the function: the split method Splits a string into substrings and then uses the result as a string
Example of splitting a string using the split function in javascript:
Script
Alert ("c: wwwccvita.jpg ");
Var path = "c: wwwccvita.jpg ";
Var arr = path. split ("");
Alert (arr );
Script
The following describes the functions:
Split Method
Splits a string into substrings and returns the result as a string array.
StringObj. split ([separator [, limit])
Parameters
StringObj
Required. String object or text to be decomposed. This object will not be modified by the split method.
Separator
Optional. A string or regular expression object that identifies whether a string is separated by one or more characters. If this option is ignored, a single array of elements containing the entire string is returned.
Limit
Optional. This value is used to limit the number of elements in the returned array.
Description
The result of the split method is a string array. In stingObj, the position where separator appears must be decomposed. The separator is not returned as part of any array element.
Example
The following example demonstrates the use of the split method.
Function SplitDemo (){
Var s, ss;
Var s = "The rain in Spain falls mainly in the plain .";
// Separate each space character.
Ss = s. split ("");
Return (ss );
}