stoneharry

Untitled

Aug 21st, 2012
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.45 KB | None | 0 0
  1. function split(str)
  2.     local b = {}
  3.     local c = 1
  4.     local d = {}
  5.     string.gsub(str, "[%w-]", function(a)
  6.         if (a == "-") then
  7.             c = c + 1
  8.         else
  9.             if (not b[c]) then
  10.                 b[c] = {}
  11.             end
  12.             table.insert(b[c], a)
  13.         end
  14.     end)
  15.     for k, v in pairs (b) do
  16.         table.insert(d, table.concat(v))
  17.     end
  18.     return d
  19. end
  20.  
  21. local string = "CHAOTIC:SCENARIO-name-0-0-name-description"
  22.  
  23. local test = split(string)
  24.  
  25. for k,v in pairs(test) do
  26.   print(v)
  27. end
Advertisement
Add Comment
Please, Sign In to add comment