Simple implementation to trim leading and trailing whitespace from a string in LUA
function trim(s) return s:match'^()%s*$' and '' or s:match'^%s*(.*%S)' end
local a = ' abcde fg ' print( a..'END' ) print(trim(a)..'END')