0

I have such string test1/test2/test3/test4/test5 How can I get those tests in separate variables or in array or smth using javascript or jquery ?

4
  • 1
    var arrTests = myString.split("/"); Commented Oct 11, 2011 at 11:22
  • possible duplicate of How do I split this string with JavaScript? Commented Oct 11, 2011 at 11:23
  • 1
    -1 for terminal laziness. Did you not bother searching first? Commented Oct 11, 2011 at 12:18
  • -100 to you. Did you not bother read books only and not visit this site at all ? Commented Oct 11, 2011 at 12:57

5 Answers 5

3
var arrayOfBits = string.split(separator)
Sign up to request clarification or add additional context in comments.

Comments

1

Use split
MN Documentation for split

var data = "test1/test2/test3/test4/test5".split("/");

Comments

1

You could use split (so no jQuery required) -

var arr = "test1/test2/test3/test4/test5".split("/");
console.log(arr);

Demo http://jsfiddle.net/ipr101/hXLE7/

Comments

1

You can use String.split(), where you specify the separator as "/" in the API, and get the array of values in return.

Comments

1

You can split a string by a delimiter.

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/split

Comments

Your Answer

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.