📅  最后修改于: 2022-03-11 14:52:31.943000             🧑  作者: Mango
String str = "Location \"Welcome to india\" Bangalore " +
"Channai \"IT city\" Mysore";
List list = new ArrayList();
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);