local function trim0( s ) return s:match("^(%d*%.?0?%d-)0*$") end print( trim0 "123.450000000" ) print( trim0 "1234500" ) print( trim0 "12345.0" )