I want to remove all spaces from a string in Lua. This is what I have tried:
string.gsub(str, \"\", \"\") string.gsub(str, \"% \", \"\") string.gsub(str, \"%s*\"
You use the following function :
function all_trim(s) return s:match"^%s*(.*)":match"(.-)%s*$" end
Or shorter :
function all_trim(s) return s:match( "^%s*(.-)%s*$" ) end
usage:
str=" aa " print(all_trim(str) .. "e")
Output is:
aae