Android/Java Regex to remove extra zeros from sub-strings

前端 未结 7 1304
闹比i
闹比i 2020-12-16 17:04

I have the following string as input :

\"2.0,3.00,-4.0,0.00,-0.00,0.03,2.01,0.001,-0.03,101\"

Final output will be like :

         


        
7条回答
  •  时光说笑
    2020-12-16 17:50

    is it possible to just use replace? example:

    str.replaceAll("\.0+,|,0+(?=\.)", ",");
    

    demo

提交回复
热议问题