String str = "1 2  3   4";
str = str.replaceAll("[\\s|\\ ]{2,}", " ");
//等於 [ \t\n\x0B\f\r] 空白字元
System.out.println(str); //1 2 3 4
arrow
arrow

    咪卡恰比 發表在 痞客邦 留言(0) 人氣()