正文Java 去掉字符串中的换行符回车符等IP云V管理员/2022-10-31/4 阅读 10/31提示:扫一扫查出行【扫一扫了解最新限行尾号】复制提示去掉一个字符串中的换行符、回车符等,将连续多个空格替换成一个空格String string = "this just a test"Pattern p = Pattern.compile("\t|\r|\n");Matcher m = p.matcher(string);string = m.replaceAll("");string = string.replaceAll(" +", " ");