GetWords

GetWords - by Mikk -

Split a string on spaces (one or more) and return as a table.

wordList = &lt;PREFIX&gt;_GetWords("string with space separated words")

Arguments

 * str : String - containing words that you would like split

Returns

 * wordList: Table - array of words in the string

Example
wordList = &lt;PREFIX&gt;_GetWords(" string with   space   separated words");

Result
wordList[1]="string" wordList[2]="with" wordList[3]="space" wordList[4]="separated" wordList[5]="words"

Code
function &lt;PREFIX&gt;_GetWords(str) local ret = {}; local pos=0; while(true) do     local word; _,pos,word=string.find(str, "^ *([^%s]+) *", pos+1); if(not word) then return ret; end table.insert(ret, word); end end