Advertisement
LPGhatguy

String Split

Jun 3rd, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. string_split = function(source, splitter)
  2. local last = 1
  3. local current
  4. local out = {}
  5.  
  6. while (true) do
  7. current = source:find(splitter, last, true)
  8.  
  9. if (not current) then
  10. break
  11. end
  12.  
  13. table.insert(out, source:sub(last, current - 1))
  14. last = current + splitter:len()
  15. end
  16.  
  17. table.insert(out, source:sub(last))
  18.  
  19. return out
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement