
lua 怎么通过空格来分割字符串
如localstr="helloiammarry"通过空格分割得到arr=["hello","i","a,","marry"]...
如 local str="hello i am marry"
通过空格分割得到
arr=["hello","i","a,","marry"] 展开
通过空格分割得到
arr=["hello","i","a,","marry"] 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
展开全部
--如果想学习更多的lua字符串模式匹配请参考《Programming in Lua》第二十章String库
local str = "hello i am marry"
local arr = {}
for w in string.gmatch(str, "%S+") do
table.insert(arr,w)
end
local str = "hello i am marry"
local arr = {}
for w in string.gmatch(str, "%S+") do
table.insert(arr,w)
end
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询