|
| JAVASCRIPT split() METHOD
The split() method splits a string by a separator that you specify. The separator can be a character, a regular expression or a substring. The sepator can also be no space (""), single space(" "), double-space(" "), etc.
The general format is:
string.split(separator, howmanytimestosplit);
The separator argument is required. The howmanytimestosplit is optional and indicates how many times the string should be split. If this argument is left out, the default will split the string right through the end.
Example: No howmanytimestosplit Specified
<script type="text/javascript">
var string="The*brown*box*is*brown";
document.write(string.split("*"));
</script>
The above will output:
Example: howmanytimestosplit Specified
<script type="text/javascript">
var string="The*brown*box*is*brown";
document.write(string.split("*", 2));
</script>
The above will output:
See Also:
|
|