JAVASCRIPT

 Home  Computers & Internet  Web Programming JAVASCRIPT
What is Javascript?
Javascript Placement
Syntax
Reserved Words
Variables
Data Types
Escaping Characters
Concatenation
Arithmetic Operators
Assignment Operators
Comparison Operators
Boolean Operators
Conditional Operator
If Statements
Else If Statements
If Else Statements
Switch Statements
While Loops
For Loops
Do While Loops
Break Statement
Continue Statement
prompt()
alert()
Date()
Event Handlers
String Object Methods
Math Object Methods
Window Object Methods
Arrays

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:

anchor() big()
blink() bold()
charAt() charCodeAt()
concat() fixed()
fontcolor() fontsize()
fromCharCode() indexOf ()
italics () lastIndexOf()
link() match()
replace () search()
slice() small()
split() strike()
sub() substr()
substring() sup()
toLowerCase() toUpperCase()
toSource() valueOf ()

Home | Privacy Policy | Terms Of Use | Contact Us