List<MessageFormatError> (@NotNull String string) { List<MessageFormatError> errors = new ArrayList<>(); int fromIndex = 0; while (true) { int currentQuoteIndex = string.indexOf('\'', fromIndex); if (currentQuoteIndex == -1) { break; } int afterContradiction = currentQuoteIndex; while (afterContradiction < string.length() && string.charAt(afterContradiction) == '\'') { afterContradiction++; } if (afterContradiction >= string.length()) { break; } fromIndex = afterContradiction; if (currentQuoteIndex + 1 == afterContradiction) { continue; } String firstPartContradiction = new StringBuilder(getStringWord(string, currentQuoteIndex - 1, i -> i - 1)).reverse().toString(); String secondPartContradiction = getStringWord(string, afterContradiction, i -> i + 1); List<String> knownSecondParts = knownContractions.get(firstPartContradiction.toLowerCase(Locale.ROOT)); if (knownSecondParts == null) { continue; } if (knownSecondParts.contains(secondPartContradiction.toLowerCase(Locale.ROOT))) { errors.add(new MessageFormatError(MessageFormatErrorType.MANY_QUOTES, currentQuoteIndex, fromIndex)); } } return errors; }