ok this topic confuses me
how would i make a string pattern that gets every digit & uppercase or lowercase letter or whitespace and puts the string into a table. if it finds a specific character then it stops, then gets the position of the character that was found and continues off putting strings after that character into a different table
for example character to find is '|'
"1dsi,gok cnmx| do46,d"
table 1 = {"1dsi", "gok cnmx"}
table 2 = {" do46", "d"}
i did this at first
for Word in string.gmatch(Message, "(%w*%s*),*|?") do
table.insert(SortedMessage, Word)
end
and for that, the output for
"1ad, fds h4 o |as56"
is
{"1ad", " fds h4 o ", "as56"}
i just have no idea how to split the rest of the groups into a different table after '|', and another one if it finds another after, etc
i tried to split it into groups but i failed miserably, heres my attempt on that
SortMessageToTable = function(Message)
local SortedMessage = {
}
local CurrentTable = {}
for w,i in string.gmatch(Message, "(%w*),*()") do
table.insert(CurrentTable, w)
print(w)
if Message:sub(i, i) == "|" then
table.insert(SortedMessage, CurrentTable)
CurrentTable = {}
end
end
table.insert(SortedMessage, CurrentTable)
return SortedMessage
end
and this is what i get for this mess: http://i.imgur.com/kazWUry.gifv
also, here's the code that reads the returned table
local SortedMessage = Commands.SortMessageToTable(Message)
for i=1, #SortedMessage do
for v=1, #SortedMessage[i] - 1 do
print(i, SortedMessage[i][v])
end
end
help would be appreciated

1 comment
woah, thank you so much. love the way you solved my problem, thank you for making it easy to understand