lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On Fri, Aug 30, 2013 at 3:52 PM, Choonster TheMage <choonster.2010@gmail.com> wrote:
local function trim0( s )
    return s:match("^(%d*%.?0?%d-)0*$")
end

print( trim0 "123.450000000" )
print( trim0 "1234500" )
print( trim0 "12345.0" )


If input is known to be good, then this works. It matches "10231.", which should probably be fine... Don't know if that smells or not.

-Andrew