code: protected static List<String> splitViewKeys(String viewKeysString) {
      List<String> splits = new ArrayList<>();
      char[] chars = viewKeysString.toCharArray();
  
      boolean betweenSquareBraces = false;
      boolean betweenQuotes = false;
      int lastMatch = 0;
  
      for (int i = 0; i < chars.length; i++) {
        if ((chars[i] == KEYS_STRING_SEPARATOR) && !betweenQuotes && !betweenSquareBraces) {
          splits.add(viewKeysString.substring(lastMatch, i));
          lastMatch = i + 1;
        }
  
        if ((chars[i] == '"') && (i == 0 || chars[i - 1] != '\\')) {
          betweenQuotes = !betweenQuotes; //toggle betweenQuotes
        }
  
        if ((chars[i] == '[') && (i == 0 || chars[i - 1] != '\\')) {
          betweenSquareBraces = true;
        }
  
        if ((chars[i] == ']') && (i == 0 || chars[i - 1] != '\\')) {
          betweenSquareBraces = false;
        }
      }
  
      //add last key if needed
      if (lastMatch < chars.length) {
        splits.add(viewKeysString.substring(lastMatch, chars.length));
      }
  
      return splits;
    }
docs: Correctly split a string containing Couchbase view keys. Uses {@code KEYS_STRING_SEPARATOR} to split the
  string, but not if the separator is found between double-quotes or square braces.
  
  @param viewKeysString string containing all Couchbase keys separated by {@code KEYS_STRING_SEPARATOR}
  @return all Couchbase keys