且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在字符串中的每个一两个字符后插入空格

更新时间:2022-12-28 16:09:54

此解决方案将每个运算符周围的空格归一化.

This solution normalizes the whitespace around each operator.

return expr.replaceAll("(?<=\\d)\\s*([-+/*])\\s*(?=\\d)", " $1 ");