Remove non applicable zeros in decimal place

I would like to seek advice on how to remove the zeros from a string. Basically the source I get the value from always gives 4 decimal places even if they are all zeros. So I would like to manipulate the data such that if the value is a whole number, remove the ‘.’ and ‘0’ entirely, and if there’s decimal place, remove the ‘0’ after the last sensible digit. Examples as follows:

123.0000 ==> 123
123.4500 ==> 123.45
123.4560 ==> 123.456
123.2080 ==> 123.208

Thank you in advance.

Assign cleanValue = If(value.Contains("."c),Decimal.Parse(value).ToString(“0.####”),Integer.Parse(value).ToString)

try this

Hi you can try this it will remove the zeros a

\.?0+$

image

str = “YourText”

System.Text.RegularExpressions.Regex.Replace(str,"\.?0+$","")

@QTH

or you can try this
System.Text.RegularExpressions.Regex.Replace(yourString,“.0+\b|(?<=.\d*?)0+\b”,“”)

Hi

This is already discussed in many post @QTH
Would recommend to have a view on unit

Cheers @QTH