Lore archive · Warcraft Wiki, 2023 dump
GetWords
Last wiki revision 2008-07-09
GetWords - by Mikk -
Split a string on spaces (one or more) and return as a table.
wordList = <PREFIX>_GetWords("string with space separated words")
- str : String - containing words that you would like split
- wordList: Table - array of words in the string
wordList = <PREFIX>_GetWords(" string with space separated words");
wordList[1]="string" wordList[2]="with" wordList[3]="space" wordList[4]="separated" wordList[5]="words"
function <PREFIX>_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
Categories
- User defined functions
Source
https://warcraft.wiki.gg/wiki/GetWords · retrieved 2023-11-13 · CC BY-SA 4.0
Converted from wikitext with templates, tables and images removed, so some sentences may be missing values.
This archive predates WoW: Forever. For collected gameplay facts see the Forever database. Search the archive.