LUA String mangling: trim a string
November 23, 2007 | Add a comment »Here’s a usefull function to trim (remove leading and/or trailing spaces) a string
function trim (s)
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
end
Here’s a usefull function to trim (remove leading and/or trailing spaces) a string
function trim (s)
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
end
Head over to http://lua-users.org/wiki/LuaShortReference to get yourself a nicely written summary of the Lua syntax and core libraries by Enrico Colombini.