I’m somewhat new to parsing Lua strings… can somebody more experienced help me out with this one?
I’m parsing the following string from a text file. I simply want to loop over the string and retrieve each number in turn, each of which will be inserted into another Lua table.
[0,-35,37,30,-37,30]
My best luck so far is this:
for val in string.gmatch(string, "(.-)%,") do
print(val)
end
But this only gets the first 5 values (out of 6) because it’s looking for a full “match” with a comma after every number, and obviously a comma directly follows only the first 5 numbers.
I know there must be a straightforward way to get all 6 values, using a particular pattern match, but the Lua pattern dictation is still throwing a wrench into my brain. If anybody can help, I’d greatly appreciate it!
Brent
[import]uid: 9747 topic_id: 4075 reply_id: 304075[/import]