int (@NotNull CharSequence buffer, int startOffset, int endOffset, @NotNull String chars) { for (int offset = startOffset, limit = Math.min(endOffset, buffer.length()); offset < limit; offset++) { char c = buffer.charAt(offset); int i; for (i = 0; i < chars.length(); i++) { if (c == chars.charAt(i)) break; } if (i >= chars.length()) { return offset; } } return endOffset; }