Advertisement
sci4me

Lua String Split (shitty)

Sep 24th, 2016
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.34 KB | None | 0 0
  1. function split(str, char)
  2.     local parts = {}
  3.        
  4.     local currentPart = {} 
  5.     for i = 1, str:len() do
  6.         local c = str:sub(i, i)
  7.         if c == char then
  8.             table.insert(parts, table.concat(currentPart))
  9.             currentPart = {}
  10.         else
  11.             table.insert(currentPart, c)
  12.         end
  13.     end
  14.    
  15.     table.insert(parts, table.concat(currentPart))
  16.    
  17.     return parts
  18. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement