// 多个空格替换为1个空格 str1 = str1.replaceAll(" +"," "); //必须是replaceAll方法,replace不可以! str1 = str1.replaceAll("\\s*"," "); //必须是replaceAll方法,replace不可以!
// 将TAB键替换为一个空格 resultStr = resultStr.replace(" ", " ");
本文出自 “◆峰回路转◇2015启程◆” 博客,请务必保留此出处http://huangfuff.blog.51cto.com/2632203/1640722
原文地址:http://huangfuff.blog.51cto.com/2632203/1640722