boolean (String text, int i) { char cur = text.charAt(i); char prev = i > 0 ? text.charAt(i - 1) : 0; if (isUpperAscii(cur)) { if (isUpperAscii(prev)) { // check that we're not in the middle of an all-caps word int nextPos = i + 1; if (nextPos >= text.length()) return false; return isLowerAscii(text.charAt(nextPos)); } return true; } if (isDigitAscii(cur)) { return true; } if (!isLetterAscii(cur)) { return false; } return i == 0 || !isLetterOrDigitAscii(text.charAt(i - 1)); }