masodikbela

luaSplit

Dec 28th, 2015
850
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.40 KB | None | 0 0
  1. function split(string_,delimiter)
  2.     local result = { }
  3.     local from  = 1
  4.     local delim_from, delim_to = string.find( string_, delimiter, from  )
  5.     while delim_from do
  6.         table.insert( result, string.sub( string_, from , delim_from-1 ) )
  7.         from  = delim_to + 1
  8.         delim_from, delim_to = string.find( string_, delimiter, from  )
  9.     end
  10.     table.insert( result, string.sub( string_, from  ) )
  11.     return result
  12. end
Advertisement
Add Comment
Please, Sign In to add comment