Hi,

I'm not a regex expert, and I can't seem to find the solution for this (need to work on my searching skills and regex ).
How can I split the input string entered into string array?

i.e.
From:
Code:
dog cat "elephant giraffe" hippo
I got the following array:
Code:
[0] = dog
[1] = cat
[2] = "elepant 
[3] = giraffe"
[4] = hippo
But I need this:
Code:
[0] = dog
[1] = cat
[2] = elepant giraffe
[3] = hippo
Or maybe some other alternatives to do the splitting?

My current code:
Code:
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String input= br.readLine().trim();
String[] tokens = input.split("\\s+)"; // regex will not handle spaces enclosed by quotes.
Thanks in advance.