Grammar
Stringobj.split ([separator[, limit]])
Parameters
Stringobj
Required option. The String object or text to be exploded. The object is not modified by the split method.
Separator
Options available. String or regular Expression object
Tips and comments
Note: If the empty string ("") is used as a, then each character in the Stringobject is split.
Note: The actions performed by String.Split () are the opposite of those performed by Array.join.
Cases
| The code is as follows |
Copy Code |
|
function Splitdemo () {
var s, SS;
var s = "The rain in Spain falls mainly in the plain.";
Decomposes at each space character.
SS = S.split ("");
return (SS);
} |
If you want to use the character in a string, you also need to escape. For example, to First Express "AAAABBBB" the string should be "aaaa\bbbb", if you want to separate it should be so to get the correct result:
Cases
| The code is as follows |
Copy Code |
|
string[] aa = "AAA\BBB\BCCC". Split (\); |
If you use the "." As a separate word, it must be written as follows: String.Split ("\.") so that the correct separation can be separated from the String.Split (".");
Cases
| The code is as follows |
Copy Code |
|
<script language= "JavaScript" >
function Spli () {
Datastr= "2,2,3,5,6,6";
var str= new Array ();
Str=datastr.split (",");
for (i=0;i<str.length; i++)
{
document.write (str[i]+ "<br/>");
}
}
Spli ();
</script> |
Note that strs=str.split (","); After the character is split, the number will be an array.