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*\"
If anyone is looking to remove all spaces in a bunch of strings, and remove spaces in the middle of the string, this this works for me:
function noSpace(str)
local normalisedString = string.gsub(str, "%s+", "")
return normalisedString
end
test = "te st"
print(noSpace(test))
Might be that there is an easier way though, I'm no expert!