lingyunlujixin 发表于 2013-2-5 01:34:24

把数值逗号分隔的函数(e.g. 123456=>123,456)

public static String cnvComma(String aValue) {    String ret = aValue;int len = (int)Math.ceil(aValue.length() / 3.0f) - 1;    while (len-- > 0) {      ret = ret.replaceFirst("^(-?\\d+)(\\d{3})", "$1,$2");    }    return ret;}// e.g. cnvComma("-123456") => -123,456// 关于正则表达式的完整文档参照附件// 也可在官网下载正则表达式完整文档(c++版)// http://www.regexlab.com/zh/
页: [1]
查看完整版本: 把数值逗号分隔的函数(e.g. 123456=>123,456)