The input is the source text, but the register of the first character of each word, which consists of three or more characters, must be inverted, and the word should be considered a sequence containing only letters (all other characters are not part of the word). For example : entrance: When I was younger I never needed exit : when I Was Younger I never needed
public static String upperWord(String input) {
Pattern p = Pattern.compile("([\\p{InCyrillic}A-Za-z0-9-,]+\\s*)");
Matcher matcher = p.matcher(input);
StringBuilder builder = new StringBuilder();
StringBuilder temp = new StringBuilder();
while (matcher.find()) {
temp.append(matcher.group());
temp.setCharAt(0, String.valueOf(temp.charAt(0)).toUpperCase().charAt(0));
builder.append(temp);
temp.setLength(0);
}
return builder.toString();
}