int (@NotNull CharSequence buffer, int offset, @NotNull String chars) { if (offset >= buffer.length()) return offset; while (true) { if (offset < 0) break; char c = buffer.charAt(offset); int i; for (i = 0; i < chars.length(); i++) { if (c == chars.charAt(i)) break; } if (i < chars.length()) break; offset--; } return offset; }