/**
 * 使用正则表达式去掉多余的“.”与“0”
 * 
 * @param str
 * @return
 */
public static String subZeroAndDot(String str) {
    if (StringUtils.isNotEmpty(str) && str.indexOf('.') >= 0) {
        // 去掉多余的0
        String newStr = str.replaceAll("0+?$", "");
        // 如最后一位是.则去掉
        return newStr.replaceAll("[.]$", "");
    }
    return str;
}

注:StringUtils是apache的commons-lang包中的。

 

相关文章:

  • 2021-08-23
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2022-03-04
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-10
  • 2022-12-23
  • 2022-02-10
相关资源
相似解决方案