public static String applyCase(@NonNls String found, @NonNls String replacement) {
    if (found.isEmpty() || replacement.isEmpty()) return replacement;

    List<String> words = collectWords(found);
    if (words.isEmpty()) {
      return replacement;
    }
    StringBuilder result = new StringBuilder();
    int index = 0;
    int start = -1;
    for (int i = 0, length = replacement.length(); i < length; i++) {
      final char c = replacement.charAt(i);
      if (Character.isLetterOrDigit(c)) {
        if (start < 0) {
          start = i;
        }
      }
      else {
        if (start >= 0) {
          buildWord(replacement.substring(start, i), analyze(words.get(index)), result);
          start = -1;
          if (index < words.size() - 1) index++;
        }
        result.append(c);
      }
    }
    if (start >= 0) {
      buildWord(replacement.substring(start), analyze(words.get(index)), result);
    }
    return result.toString();
  }
public static String applyCase(@NonNls String found, @NonNls String replacement)