int (@NotNull String candidateName, char @NotNull [] name_pattern, char @NotNull [] NAME_PATTERN) { int candidatePos = candidateName.length(); int pos; for (pos = name_pattern.length; pos > 0; pos--) { char c = name_pattern[pos - 1]; if (!Character.isLetterOrDigit(c)) continue; char C = NAME_PATTERN[pos - 1]; for (candidatePos--; candidatePos >= 0; candidatePos--) { char candidateC = candidateName.charAt(candidatePos); if (candidateC == c || candidateC == C) { break; } } if (candidatePos < 0) { break; } } return pos; }