1

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

Gumbo
657k112 gold badges792 silver badges852 bronze badges
asked Feb 4, 2010 at 9:57

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
answered Feb 4, 2010 at 9:58
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"]
answered Feb 4, 2010 at 9:57

Comments

0

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

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

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

answered Feb 4, 2010 at 9:59

1 Comment

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.