How to split a string in JavaScript with the "," as seperator?
3 Answers
var splitString = yourstring.split(',');
See split
var str = "test,test1,test2";
var arrStr = str.split(',');
var arrLength = arrStr.length; //returns 3
Comments
var expression = "h,e,l,l,o";
var tokens = expression.split("\,");
alert(tokens[0]);// will return h
1 Comment
Matt Ellen
why are you splitting on
\,? Is that just a typo?