Lua 5.2/Split() function

I haven’t wanted Lua 5.2 in Codea, until I learned about the split/join functions. Of the Lua version of Codea could be updated ASAP, that would save me a lot of work. Thanks!
Look here to learn about Split/Join:

what do you mean? Those functions are for 5.1 as well…

@gunnar_z - They don’t seem to be working in Codea.

note that some of those have been created for 5.0, which is not 100% compatible with 5.1 (just like 5.1 is not 100% compatible with 5.2, which is why just plugging in the new interpreter into codea is going to cause some grief…,). Which example were yiu trying, and how does it not work?

@gunnar_z - the functions Split() and Join() are of Lua 5.2, so none will work. I made a workaround, so don’t worry about it. I might try and write my own version of these functions.

There are no functions split() and join() in 5.2 . There is table.concat(), which is somewhat equivalent to join(), and string.gsub(), which can be used to make sth like split().

-- Compatibility: Lua-5.1
function split(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
      last_end = e+1
      s, e, cap = str:find(fpat, last_end)
   if last_end <= #str then
      cap = str:sub(last_end)
      table.insert(t, cap)
   return t


@Diablo76 - Cool. Thanks!