faqts : Computers : Programming : Languages : JavaScript : Language Core : Strings

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 7 people (100%) answered Yes
Recently 7 of 7 people (100%) answered Yes

Entry

How can i get the count of the number of elements after using the string.split function?

Dec 12th, 2001 17:57
Jean-Bernard Valentaten, Justin Pradier,


Well, since the split() function returns an array, it is of course the
length of the array :)
function howManyElements(stringToSplit, splitterString)
{
    var myArray = new Array();
    myArray = stringToSplit.split(splitterString);
    return myArray.length;
}
HTH,
Jean