lua中字符串过滤中文
2019-11-06 本文已影响0人
东方小白
首先要判定有没有中文,这个参考
云木大大
的这篇文章
判定完中文后 我们要过滤出来
比如
local temp = "我们We123hahha哈哈哈哈7777"
temp2 = string.gsub(temp,'[%w]+',"")
print(temp2)
print(temp)
print(characters(temp2, 2))
打印出 字符是12,因为这里设定的中文是一个中文俩个字节
