Remove zeroes after three digit after decimal

Hi All,

I need to remove any zeroes after any integer digit after decimal.

for example if my value is $0.04500 USD, it should consider 0.045,

if the value is $0.698250 USD it should consider as 0.69825 only

and also remove $ , SPACE AND USD VALUE .

For example $0.69825 USD should be 0.69825 only. Can I achieve this in single expression?

@dutta.marina

Try this regex

\d+\.\d+[1-9]+

cheers

@Anil_G

Basically my actual value in Queue is 1.400000 . When it gets updated in application its becomes $1.40 USD
I have to compare and see its the same value . If its zero it should consider only one zero after any integer digit after decimal

For example

Make 1.400000 as 1.40 and $1.40 USD as 1.40

Similarly 1.00000 as 1.00 and $1.00 USD as 1.00
Similarly $0.0405 USD as 0.0405 and 0.040500 as 0.0405


If there multiple zeroes after integer it should consider 1.40(only one zero after integer digit) and remove $ and USD Sign

Hi whats about split and replace options?

Ex1: [quote=β€œdutta.marina, post:3, topic:784225”]
Make 1.400000 as 1.40 [/quote]

strPart1 = yourString.Split(".β€œc)(0)
strPart2 = yourString.Split(”."c)(1)

strFinal = strPart1 + β€œ.” + strPart2.substring(0,2)

Ex2: [quote=β€œdutta.marina, post:3, topic:784225”]
$1.40 USD as 1.40
[/quote]

yourString = yourString.Replace(β€œ$”,β€œβ€)
yourString = yourString.Replace(β€œUSD”,β€œβ€).Trim

If you need doubleValues you can use Convert.toDouble(yourString)

Cheers!

@dutta.marina

Please try this

\d+\.\d{2}\d*(?<=[1-9])|\d+\.\d{2}

Cheers

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.