I need to separate words by space separated in java, so I used a function .splitto achieve such as below
String keyword = "apple mango ";
String keywords [] = keyword .split(" ");
The above code works fine, but the only thing is that sometimes the keyword will contain a keyword such as "fruit jack" , "ice cream" with double quotes like: shown below
String keyword = "apple mango \"jack fruit\" \"ice cream\"";
In this case, I need to get 4 words, for example, apple , mango , fruit jack , ice cream in an array of keywords
Can someone tell me some solution for this
source
share