1

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

3 Answers 3

5
var splitString = yourstring.split(',');

See split

var str = "test,test1,test2";
var arrStr = str.split(',');
var arrLength = arrStr.length; //returns 3
Sign up to request clarification or add additional context in comments.

Comments

3

Use split to split your string:

"foo,bar,baz".split(",")  // returns ["foo","bar","baz"]

Comments

0

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

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

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

1 Comment

why are you splitting on \,? Is that just a typo?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.