Q:

Javascript - cutting out part of a string

Hello everyone,
I'm trying to find the best way to cut out specific parts of the below input string.
I'm using a white space (' ') as a separator. But I'm unable to cut out the required parts
 and assign them into respective variables.  
var input = "/w user1 message"

var user = input.substring(2, input.indexOf(' '));?? 
var message = ???

expected result: 
user = "user1"
message = "message"

It only works when the empty spaces are replaced with a coma or any other separator. 
Is there any specific reason why iit's not working with spaces? 
Thanks in advance,
Alex

A:

I would recommend using split, it creates an array and you can just access the array by index
http://jsfiddle.net/PJH28/
var input = "/w user1 message"

var inputParts = input.split(' ');
var message = inputParts[2];
console.log(message);

