tags:

views:

112

answers:

3

How to split a string in JavaScript with the "," as seperator?

+3  A: 

Use split to split your string:

"foo,bar,baz".split(",")  // returns ["foo","bar","baz"]
Gumbo
+5  A: 
var splitString = yourstring.split(',');

See split

var str = "test,test1,test2";
var arrStr = str.split(',');
var arrLength = arrStr.length; //returns 3
rahul
A: 

var expression = "h,e,l,l,o";

var tokens = expression.split("\,");

alert(tokens[0]);// will return h

Ravia
why are you splitting on `\,`? Is that just a typo?
Matt Ellen