SHARE
TWEET

string comma to table thing

BobMe Sep 20th, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Made by Memo1332/Denizen Donut you HECC
  2.  
  3. -- This could be used as arguments for chat based commands; which it is in new MAH, however it is opensource and free to use
  4. unlike the other new MAH scripts that are protected by copyright.
  5.  
  6. function seperatevars(x,sign)
  7.     local tab = {}
  8.     local tat = {}
  9.     for i=1,#x do
  10.         if string.sub(x,i,i) == sign then
  11.             table.insert(tab,i)
  12.         end
  13.     end
  14.     for i=1,#tab do
  15.         if i ~= 1 and i ~= #tab then
  16.             table.insert(tat,string.sub(x,tab[i]+1,tab[i+1]-1))
  17.         elseif i == #tab then
  18.             table.insert(tat,string.sub(x,tab[i]+1))
  19.         elseif i == 1 then
  20.             table.insert(tat,string.sub(x,1,tab[i]-1))
  21.         end
  22.     end
  23.     return tat
  24. end
  25.  
  26. local kek = seperatevars("nani,not nani,actually; yes nani,no. not nani.,AAAAAAAAAAAAAAAAAAAAAAAAAA",",")
  27.  
  28. if kek ~= nil then
  29.     for i=1,#kek do
  30.         print(kek[i])
  31.     end
  32. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top