public static String formatNumber( String iniNum, int split ){
        // ① 去掉所有逗号,并把串倒过来。
        StringBuffer tmp = new StringBuffer().append( iniNum.replaceAll(",", "") ) .reverse();


        // ② 替换这样的串:连续split位数字的串,其右边还有个数字,在串的右边添加逗号
        String retNum = Pattern.compile( "(\\d{" + split + "})(?=\\d)" ) .matcher( tmp.toString() ).replaceAll("$1,");


        // ③ 替换完后,再把串倒回去返回
        return new StringBuffer().append( retNum ).reverse().toString();
    }

相关文章:

  • 2021-09-25
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2021-12-17
  • 2022-12-23
猜你喜欢
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
  • 2022-01-10
  • 2022-12-23
相关资源
相似解决方案