I'm having some trouble with what I believe is this commonly used string split function for 5.1:
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
}
I'm using Lua version 5.2 and I was wondering if anyone has or knows of a string split function for 5.2, or if they could confirm or deny if this code would experience problems running in 5.2? Here's a link to my original problem for reference.
There will be no issues with that split function, from my POV.
note comment will be added, because of old(5.0) table length syntax. http://www.lua.org/pil/19.1.html
There was nothing, that can cause an error in such split implementation( It's known utility function, and I used in in multiple 5.2 projects, never have any problem's)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With