使用java正则表达式去掉多余的.与0

来源:互联网 发布:界面汉化软件 编辑:程序博客网 时间:2024/06/08 06:51
 /**
     * 使用java正则表达式去掉多余的.与0 
     * @Title: subZeroAndDot 
     * @param s
     * @return 
     * String 
     * @author wsx
     * @since 2016-7-21 V 1.0
     */
    public static String subZeroAndDot(String s){  
        if(s.indexOf(".") > 0){  
            s = s.replaceAll("0+?$", "");//去掉多余的0  
            s = s.replaceAll("[.]$", "");//如最后一位是.则去掉  
        }  
        return s;  
    }  
0 0