本文介绍了删除前导0到小数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要删除十进制数字中的前导零.
I want to remove the leading zeros in the decimal numbers.
所以我希望输出应该是 .324
不是0.324
.我试过str.replaceFirst("^0+(?!$)", "");
没用,我也试过正则表达式!没结果!是的,我正在使用BigDecimal.
So i want the output should be .324
not0.324
.I tried str.replaceFirst("^0+(?!$)", "");
Didn't work and i also tried the regex!No results!And yes I am working with BigDecimal.
推荐答案
尝试一下
str = str.replaceFirst("^0\\.", ".");
这篇关于删除前导0到小数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!