Advertisement
Bolodefchoco_LUAXML

[String] string.split

Feb 7th, 2016
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.53 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 07/02/2016
  3. --Last update: 25/05/2016
  4. --[[ Notes:
  5.     Does:
  6.         Divide a string e vários pedaços de valores padronizados numa tabela
  7.     Args:
  8.         str --> String
  9.         split --> Padrão do split (Exemplo: [^%s]+)
  10.         id --> Tipo de split
  11.             0 == [^split]+
  12.             1+ == . * id
  13. ]]--
  14.  
  15. string.split=function(str,split,id)
  16.     local list={}
  17.     for val in string.gmatch(str,id and (id==0 and '[^'..(split or '%s')..']+' or string.rep('.',id)) or split) do
  18.         table.insert(list,val)
  19.     end
  20.     return list
  21. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement