Cue the zealot with the LPeg answer in 3...2...1..
local lpeg = require"lpeg"
local P, R, C = lpeg.P, lpeg.R, lpeg.C
local integer = R("09")^1
local mant = P"." * integer
local number = C(integer * (mant + -1))
local trimmed_mant = P"." * (R"09"^1 - (P"0"^0 * -1))
local trimmed_number = C(integer * (P"." * R"09" * (R"09"- (P"0"^0 * -1))^0)^-1)
local n1 = "123.450000000"
local n2 = "1234500"
local n3 = "12345.00"
print(trimmed_number:match(n1))
--> 123.45
print(trimmed_number:match(n2))
--> 1234500
print(trimmed_number:match(n3))
--> 12345.0