Here you can find the source of extractItems(String items)
public static List<String> extractItems(String items)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { /**/*from w w w. ja v a2s .co m*/ * splits a string of type {("A","B<C,D>","C")} into ["A", "B<C,D>", "C"] * */ public static List<String> extractItems(String items) { List<String> itemList = new ArrayList<String>(); if (items == null) return itemList; items = items.replace(" ", ""); //remove all spaces if (items.split("\"(.)*\"").length == 1) return itemList; String[] arrayItems = items.split("\","); for (int i = 0; i < arrayItems.length; i++) { //there is exactly one " in each arrayItem[i], and we need the string from the right of it String[] rightStr = arrayItems[i].split("\""); if (rightStr.length > 0) itemList.add(rightStr[1]); } return itemList; } }