我检查字符串中是否有非字母数字字符。
if(str:match("%W")) then
--make str alpha-numeric
end
如何使用lua从字符串中删除所有非字母数字字符?
使用 gsub (Egor Skriptunoff建议的)。
str = str:gsub('%W','')
就像这样你忘了+
if(str:match("%W+")) then --if it contain alpha
number = str:match("%d+")
alpha = str:match("%W+")
end