我是靠谱客的博主 时尚电灯胆,这篇文章主要介绍lua 字符串分割函数,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
lua 字符串分割函数 ------------------------------------------------------- -- 参数:待分割的字符串,分割字符 -- 返回:子串表.(含有空串) function lua_string_split(str, split_char) local sub_str_tab = {}; while (true) do local pos = string.find(str, split_char); if (not pos) then local size_t = table.getn(sub_str_tab) table.insert(sub_str_tab,size_t+1,str); break; end local sub_str = string.sub(str, 1, pos - 1); local size_t = table.getn(sub_str_tab) table.insert(sub_str_tab,size_t+1,sub_str); local t = string.len(str); str = string.sub(str, pos + 1, t); end return sub_str_tab; end local str = "1,2,3,4,5,6,7,8,9" local ta = lua_string_split(str,",") local size = table.getn(ta) for i = 1,size ,1 do print(ta[i]) end

 

最后

以上就是时尚电灯胆最近收集整理的关于lua 字符串分割函数的全部内容,更多相关lua内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(92)

评论列表共有 0 条评论

立即
投稿
返回
顶部