public static @Nullable String trimBeforeLastSpace(final String suggestion, final String input) {
        final int lastSpace = input.lastIndexOf(' ');
        // No spaces in input, don't do anything
        if (lastSpace == -1) {
            return suggestion;
        }

        if (suggestion.toLowerCase(Locale.ROOT).startsWith(input.toLowerCase(Locale.ROOT).substring(0, lastSpace))) {
            return suggestion.substring(lastSpace + 1);
        }

        return null;
    }
Trims before the last space from suggestion, if it matches input tokens.

@param suggestion suggestion text
@param input      current input
@return filtered suggestion text
cloud-core/src/main/java/org/incendo/cloud/util/StringUtils.java