(1)匹配一个或多个空格的正则表达式:\\s+
String[] newStr = str.trim().split("\\s+");
(2)匹配二个或多个空格的正则表达式:\\s{2,}
String str = new String("I am a good boy! ");
String newStr = str.replaceAll("\\s{2,}", " ").trim();
(1)匹配一个或多个空格的正则表达式:\\s+
String[] newStr = str.trim().split("\\s+");
(2)匹配二个或多个空格的正则表达式:\\s{2,}
String str = new String("I am a good boy! ");
String newStr = str.replaceAll("\\s{2,}", " ").trim();