Javascript to Seprate a string into array of strings on base of a character or string in

In Javascript you can very easily seprate a string in an array of strings on base of a character or sub-string seprator using split function

array=string.split(seprator);


See following example

var string1= "this is box and who is going and we are one";
strAry= string1.split("and");

Now after execution created array will have following values
strAry[0] => this is car
strAry[1] =>
who is going
strAry[2] =>
we are one

Posted in |