lua 拆分成词 [英] lua split into words
本文介绍了lua 拆分成词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 lua 中有一个字符串.
I have a string in lua.
它是一堆 [a-zA-Z0-9]+ 由数字(1 个或多个)空格分隔.
It's a bunch of [a-zA-Z0-9]+ separated by a number (1 or more) spaces.
如何获取字符串并将其拆分为字符串表?
How do I take the string and split it into a table of strings?
推荐答案
s = "foo bar 123"
words = {}
for word in s:gmatch("%w+") do table.insert(words, word) end
这篇关于lua 拆分成词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文