function split(str,delim)
assert (type (delim) == "string" and string.len (delim) > 0,"bad delimiter")
if delim==nil then
delim="%s"
end
table={}
i=1
for w in string.gmatch(str,"[^"..delim.."]+") do
table[i]=w
i=i+1
end
return table
end
assert (type (delim) == "string" and string.len (delim) > 0,"bad delimiter")
if delim==nil then
delim="%s"
end
table={}
i=1
for w in string.gmatch(str,"[^"..delim.."]+") do
table[i]=w
i=i+1
end
return table
end
本文深入探讨了使用 Lua 编程语言实现的 `functionsplit` 函数,该函数用于根据指定的分隔符将字符串拆分为数组。通过实例分析,读者将学习如何高效地进行字符串解析,并在实际项目中应用这一技巧。

7702

被折叠的 条评论
为什么被折叠?



