How would I remove non-letters in a string?

That’s happening because。、 ؟, aren’t considered ponctuation by lua. Only way to do this is, loop manually, through the string (after we apply the normal gsub), and gsub every character you want to remove that’s stored in a table.

local specialChars = {"。","、", "؟"}
local str = "!无。$、¥『山田太郎』"
str = str:gsub("[%d%p]+", "") --do a first run

for i = 1, #str do
     local current = string.sub(str, i, i) --current character in the string
     for i, v in pairs(specialChars) do
          if current = v then
                str = str:gsub(current, "")
          end
     end
end

I’m gonna assume this is going to be an expensive process

1 Like