If you are familiar with the use of the split function in Javascript, I will share with you here. I believe this article will certainly help you gain some benefits.
Use of the split function in Javascript
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 split function:
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 function.
- FunctionSplitDemo (){
- Vars, ss;
- Vars = "TheraininSpainfallsmainlyintheplain .";
- // Separate each space character.
- Sss = s. split ("");
- Return (ss );
- }