I'm trying to parse input on spaces and put these tokens into an array. But taked quoted string as a one word. For example, assume input is:
dsas r2r "this is a sentence" asd
and array elements should be:
array[0]="dsas"
array[1]="r2r"
array[2]="this is a sentence"
array[3]="asd"
To solve the problem I used split method but it didn't help to me
String input1=input.nextLine();
input1=input1.trim();
String delims="[ \"]+";
String[] array=input1.split(delims);
How can I fix this problem? I have to put tokens into an array and i have to don't use arraylist.