Advertisement
BobMe

Seperate word thing

Aug 28th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. phrase = "lol so I want to make a algorithm that finds seperate words and puts them in a table which it seems simple enough to do"
  2.  
  3. local tab = {}
  4. local lastnum = 0
  5.  
  6. for i=1,#phrase do
  7. if string.sub(phrase,i,i) == " " then
  8. table.insert(tab,string.sub(phrase,lastnum,i-1))
  9. lastnum = i+1
  10. end
  11. end
  12. table.insert(tab,string.sub(phrase,lastnum,#phrase))
  13.  
  14. for i=1,#tab do
  15. print(i,tab[i])
  16. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement