I want to make a function that searches for | (pipe symbol) and returns each string between the mathes. I'm not very good with string.find or string.gmatch. I read the documentation but I still don't understand. What I want is:
function explode(text_ex, needle)
local array={}
_, count = string.gsub(text_ex, needle, needle)
for index=1,count+1 do
i, j = string.find(text_ex, needle)
if i == nil or j==nil then
i=0
j=0
end
table.insert(array,string.sub(text_ex, 1, i-1))
text_ex=string.sub(text_ex, j+1 )
end
return array
end
Where:
text_ex is the string
needle is the divider