public static String stripSuffix(String string, String suffix) {
        int index = string.lastIndexOf(suffix);
        return index == -1 ? string : string.substring(0, index);
    }
This will truncate sequences in a string of the same character that exceed the maximum
allowed length.

@return The same string or a new one if truncation is done.
vespajlib/src/main/java/com/yahoo/text/StringUtilities.java