This should count the number of ‘?’ in the supplied string (‘message’) and for each of those, format them into a ‘term’ which would look something like this:
string: ?t:this is a value; ?r:this is another value with a diff term!;
formatted:
{
["t"] = "this is a value",
["r"] = "this is a value with a diff term!"
}
From information found online and through the docs I’ve understood this should ahcive that:
for i = 1,select(2,message:gsub("?","")) do
warn(i)
local foundStart = string.find(message,"?",I)
local foundEnd = string.find(message,":",i)
print("INDEX:",foundStart,foundEnd)
if foundStart and foundEnd then
local term = getTerm(message:sub(foundStart+1,foundEnd-1))
if term then
print("TERM:",term)
local valueEnd = string.find(message,";",i)
print("ENDINDEX:",valueEnd)
if valueEnd then
local value = message:sub(foundEnd+1,valueEnd-1)
print("VALUE:",value)
if value then
returnInfo[term] = value
end
end
end
end
end
Yet when I run this; I get the following output:
(2 should be the second value, not the first one)
I assume I’m either misunderstanding the docs or misunderstanding the use case of string.find (or maybe even another issue I failed to spot!) Any help is much appreciated, thanks.