Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用这两个正则表达式语句。我只想使用一个正则表达式规则来减少所有类型空格的代码
strTestIn = strTestIn.replaceAll("[ ]+", " "); strTestIn = strTestIn.replaceAll("(\\t)+", " ");
我需要使用什么正则表达式?
strTestIn = strTestIn.replaceAll("\\s+", " ");
查看Pattern类
\s匹配空白字符:[ \t\n\x0B\f\r]
\s
[ \t\n\x0B\f\r]