String (@NotNull String text) { if (!text.contains("040")) return text; StringBuilder result = new StringBuilder(); int i = 0; int length = text.length(); while (i < length) { int nSlashes = 0; int next; while (i < length && (next = PsiLiteralUtil.parseBackSlash(text, i)) != -1) { nSlashes++; i = next; } if (i >= length) { result.append(StringUtil.repeatSymbol('\\', nSlashes)); break; } if (nSlashes % 2 != 0 && StringUtil.startsWith(text, i, "040")) { result.append(StringUtil.repeatSymbol('\\', nSlashes - 1)).append(" "); i += 3; continue; } result.append(StringUtil.repeatSymbol('\\', nSlashes)).append(text.charAt(i)); i++; } return result.toString(); }