// 多个空格替换为1个空格 str1 = str1.replaceAll(" +"," "); //必须是replaceAll方法,replace不可以! str1 = str1.replaceAll("\\s*"," "); //必须是replaceAll方法,replace不可以!
// 将TAB键替换为一个空格 resultStr = resultStr.replace(" ", " ");
时间: 2024-10-11 11:02:21
// 多个空格替换为1个空格 str1 = str1.replaceAll(" +"," "); //必须是replaceAll方法,replace不可以! str1 = str1.replaceAll("\\s*"," "); //必须是replaceAll方法,replace不可以!
// 将TAB键替换为一个空格 resultStr = resultStr.replace(" ", " ");