Java 去除String 中空格
>str.trim(); //去掉首尾空格
>str.replace(" ",""); //去除所有空格,包括首尾、中间
>str.replaceAll(" ", ""); //去掉所有空格,包括首尾、中间
>str.replaceAll(" +",""); //去掉所有空格,包括首尾、中间
>str.replaceAll("\\s*", ""); //可以替换大部分空白字符, 不限于空格 ;
>ps:\\s* 可以匹配空格、制表符、换页符等空白字符的其中任意一个。
FlowLiver Notes

浙公网安备 33010602011771号