就是这样:
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);输出:
[Location, "Welcome to india", Bangalore, Channai, "IT city", Mysore]
正则表达式简单地说
[^"]
-令牌以不同于"
S*
-后跟零个或多个非空格字符...or...
".+?"
- “符号-后跟任何符号,直到另一个符号"
。



