合并字符串中的多个空格



String strResult= "";
String str="Senators are still in the nation’s Capitol.";
Pattern pattern = Pattern.compile("\\s+");
Matcher matcher = pattern.matcher(str);
strResult= matcher.replaceAll(" ");
System.out.println(strResult);


Senators are still in the nation’s Capitol.