Skip to Content
0
May 09, 2008 at 02:09 AM

RegEx ?

40 Views

All,

I need to remove trailing zeros in numbers. Given the value is held in a decimal variable called "duration", how do I achieve the following when outputting to String:

"Duration" value             Required Output
1.550                --------->     1.55
1.5000              --------->     1.5
2.0000              --------->     2
0.0100              --------->     0.01

I am doing this for PHP scripting