如何在Lua中通过分号拆分字符串?
local destination_number="2233334;555555;12321315;2343242"
在这里,我们可以看到分号(;)的多次出现,但我只需要输出上面字符串中第一次出现分号之前的内容。
尝试的代码:
if string.match(destination_number, ";") then
for token in string.gmatch(destination_number, "([^;]+),%s*") do
custom_destination[i] = token
i = i + 1
end
end
输出:
2233334
我尝试了上面的代码,但对Lua脚本语言还是新手,无法得到精确的语法。