P. S. I also know that you can use
string.gsub(str, " ", "")
But that removes all spaces, not just ones at the front and back.
I’m pretty sure I misunderstood your post, but if you’re talking about removing spaces before and after a string, this might work.
local str = " string string "
string.sub(str, 2, #str-1)
Hmm, ok. The thing is it only removes the first space from the front or end, and not any others. It’s probably fine for what I need though.
local function trim(str)
return string.gsub(str, "^%s*(.-)%s*$", "%1")
print("/" .. trim(" \t jello \n \t ") .. "/") --> /jello/
From string - Lua trailing space removal - Stack Overflow