3
我遇到一些麻煩,我相信這是對5.1這個常用字符串分割功能:Lua的字符串分割爲5.2
utils = {
split = function(str, pat)
local t = {} -- NOTE: use {n = 0} in Lua-5.0
local fpat = "(.-)" .. pat
local last_end = 1
local s, e, cap = str:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(t,cap)
end
last_end = e+1
s, e, cap = str:find(fpat, last_end)
end
if last_end <= #str then
cap = str:sub(last_end)
table.insert(t, cap)
end
return t
end
}
我使用Lua版本5.2,我想知道如果任何人有或知道5.2的字符串分割函數,或者如果他們可以確認或否認這些代碼是否會遇到5.2中遇到的問題?這裏是我的原始問題的鏈接reference.
我相信你有誤診的問題。看到我對Schollii對你的另一個問題的回答(以及他們最近的評論也和我說的一樣)。 –