当长度超过51时将一个字符串分割成另一个打印,不要分割一个单词(Lua)

我试图在字符串长度超过51时对其进行拆分。我认为我的代码没问题,但是 Lua Demopage 总是显示“尝试调用空值(字段'gfind')”

这是我的代码:

function _say_(text)
    local temptext = ""
    local tbl = {}
    for word in string.gfind(text,“%a +”)do
        if string.len(temptext ..“” ..word)> = 52 then
            table.insert(tbl,temptext)
            temptext = word
        else
            temptext = temptext ..“” ..word
        end
    end
    table.insert(tbl,temptext)
    for i = 1,table.getn(tbl)do
        print(tbl [i])
    结束
end
点赞