String (@NotNull String string) { final String result = StringUtil.replace( string, Arrays.asList("\\n\\r", "\\n"), Arrays.asList("\\n\\r\" + \n\"", "\\n\" + \n\"") ); final String redundantSuffix = " + \n\"\""; return result.endsWith(redundantSuffix) ? result.substring(0, result.length() - redundantSuffix.length()) : result; }