Posted 28 August 2012 - 03:22 PM
function getwords(str)
newstr = {}
num = 0
for word in string.gmatch(str, "%a+") do
table.insert(newstr, word)
end
return newstr
end
I'm trying to make a function that separates a string into an array containing every word in the string. I'm pretty new with arrays, but I found this string.gmatch function online that looks promising. Is this function default and/or is there an easier way?Solved. Apparently that code just isn't going to work and Lua already wrote something to do exactly what I'm trying to do.