java split string on two or more spaces except for words in quotes
[Location, "Welcome to india", Bangalore, Channai, "IT city", Mysore]
java split string on two or more spaces except for words in quotes
[Location, "Welcome to india", Bangalore, Channai, "IT city", Mysore]
java split string on two or more spaces except for words in quotes
String str = "Location \"Welcome to india\" Bangalore " +
"Channai \"IT city\" Mysore";
List<String> list = new ArrayList<String>();
Matcher m = Pattern.compile("([^\"]\\S*|\".+?\")\\s*").matcher(str);
while (m.find())
list.add(m.group(1)); // Add .replace("\"", "") to remove surrounding quotes.
System.out.println(list);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us