日期:2014-05-20 浏览次数:20607 次
public class BlankTest { public static void main(String[] args) { System.out.println(deleteMulBlank("hello yyo koko !!!")); System.out.println(deleteMulBlank("afsaf fdsfdf fsdfsdf fs fs dfsdfsfsdf sdfsdfsdf sdfsdf sd fs f sdf sdf sdfd")); } public static String deleteMulBlank(String str){ return str.replaceAll("[ ]{2,}", " "); } }