String (@NotNull String text, @NotNull String subString, boolean includeLast) { int i = text.lastIndexOf(subString); if (i == -1) return text; return includeLast ? text.substring(0, i + subString.length()) : text.substring(0, i); }