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

前端 未结 7 1306
闹比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:52

    You can do it with 2 times replacement :

    first use \.0+(?=(,|$)) and replace with ""

    then use (?!(^|,))-0(?=(,|$)) and replace it with "0"

    0 讨论(0)
提交回复
热议问题