首页 > 解决方案 > 删除回车时replaceAll不起作用

问题描述

我正在使用此调用从字符串中删除回车符

input = input.replaceAll("[\r\n]", "");
return input;

但是当将此字符串作为输入时:http://localhost:4200/\n\rhome

我得到以下输出:http://localhost:4200/\\n\\rhome

知道为什么吗?我该如何解决这个问题?

标签: javaregex

解决方案


推荐阅读