code: public static List<String> valueSplit(String str, String valueRegex, String separatorRegex) {
      Pattern vPat = Pattern.compile(valueRegex);
      Pattern sPat = Pattern.compile(separatorRegex);
      List<String> ret = new ArrayList<String>();
      while (str.length() > 0) {
        Matcher vm = vPat.matcher(str);
        if (vm.lookingAt()) {
          ret.add(vm.group());
          str = str.substring(vm.end());
          // String got = vm.group();
          // System.err.println("vmatched " + got + "; now str is " + str);
        } else {
          throw new IllegalArgumentException("valueSplit: " + valueRegex + " doesn't match " + str);
        }
        if (str.length() > 0) {
          Matcher sm = sPat.matcher(str);
          if (sm.lookingAt()) {
            str = str.substring(sm.end());
            // String got = sm.group();
            // System.err.println("smatched " + got + "; now str is " + str);
          } else {
            throw new IllegalArgumentException("valueSplit: " + separatorRegex + " doesn't match " + str);
          }
        }
      } // end while
      return ret;
    }
docs: Split a string into tokens.  Because there is a tokenRegex as well as a
  separatorRegex (unlike for the conventional split), you can do things
  like correctly split quoted strings or parenthesized arguments.
  However, it doesn't do the unquoting of quoted Strings for you.
  An empty String argument is returned at the beginning, if valueRegex
  accepts the empty String and str begins with separatorRegex.
  But str can end with either valueRegex or separatorRegex and this does
  not generate an empty String at the end (indeed, valueRegex need not
  even accept the empty String in this case.  However, if it does accept
  the empty String and there are multiple trailing separators, then
  empty values will be returned.
  
  @param str The String to split
  @param valueRegex Must match a token. You may wish to let it match the empty String
  @param separatorRegex Must match a separator
  @return The List of tokens
  @throws IllegalArgumentException if str cannot be tokenized by the two regex