string patterns, split sets of strings into various tables? [closed]
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 '|'
3 | table 1 = { "1dsi" , "gok cnmx" } |
4 | table 2 = { " do46" , "d" } |
i did this at first
1 | for Word in string.gmatch(Message, "(%w*%s*),*|?" ) do |
2 | table.insert(SortedMessage, Word) |
and for that, the output for
is
1 | { "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
01 | SortMessageToTable = function (Message) |
02 | local SortedMessage = { |
06 | local CurrentTable = { } |
07 | for w,i in string.gmatch(Message, "(%w*),*()" ) do |
08 | table.insert(CurrentTable, w) |
10 | if Message:sub(i, i) = = "|" then |
11 | table.insert(SortedMessage, CurrentTable) |
16 | table.insert(SortedMessage, CurrentTable) |
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
1 | local SortedMessage = Commands.SortMessageToTable(Message) |
3 | for i = 1 , #SortedMessage do |
4 | for v = 1 , #SortedMessage [ i ] - 1 do |
5 | print (i, SortedMessage [ i ] [ v ] ) |
help would be appreciated
Locked by User#24403
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?