private static List<String> splitInput(final String userInput) {
        final List<String> tokens = new ArrayList<>();
        final String cleanedInput = userInput.trim();

        int start = 0;
        boolean insideQuotes = false;
        boolean wasInsideQuotes = false;
        char lastChar = 0;
        int unEscapedQuoteCount = 0;

        try {
            for (int current = 0; current < cleanedInput.length(); current++) {
                final char currentChar = cleanedInput.charAt(current);
                if (currentChar == QUOTE_CHAR && lastChar != ESCAPE_CHAR) {
                    unEscapedQuoteCount++;
                    if (!insideQuotes) {
                        // start of quotes
                        wasInsideQuotes = true;
                    }
                    insideQuotes = !insideQuotes; // toggle state
                }

                boolean atLastChar = (current == cleanedInput.length() - 1);

                if (atLastChar) {
                    if (wasInsideQuotes) {
                        // Strip the quotes off
                        tokens.add(deEscape(cleanedInput.substring(start + 1, cleanedInput.length() - 1)));
                    } else {
                        tokens.add(deEscape(cleanedInput.substring(start)));
                    }
                } else if (currentChar == SPLIT_CHAR && !insideQuotes) {
                    // allow for multiple spaces
                    if (currentChar != lastChar) {
                        if (wasInsideQuotes) {
                            // Strip the quotes off
                            tokens.add(deEscape(cleanedInput.substring(start + 1, current - 1)));
                            // clear the state
                            wasInsideQuotes = false;
                        } else {
                            tokens.add(deEscape(cleanedInput.substring(start, current)));
                        }
                    }
                    start = current + 1;
                }
                lastChar = currentChar;
            }
            if (unEscapedQuoteCount % 2 != 0) {
//                LOGGER.trace("Odd number of quotes ({}) in input [{}], can't parse",
//                        unEscapedQuoteCount, userInput);
                tokens.clear();
            }
        } catch (Exception e) {
//            LOGGER.trace("Unable to parse [{}] due to: {}", userInput, e.getMessage(), e);
            // Don't want to throw as it may be unfinished user input.
        }
//        LOGGER.trace("tokens {}", tokens);
        return tokens;
    }
Split the input on spaces with each chunk optionally enclosed with a double quotes.
Should ignore leading, trailing repeated spaces.

@return An empty list if it can't parse
stroom-core-shared/src/main/java/stroom/security/shared/QuickFilterExpressionParser.java