How do i split these strings from a table

Howdy, I’m trying to get a table to return something specific; I’ll show an example

local exampleTable = {
'w1',
'w2',
'w3',
'w4',
'w5',
'a1',
'a2',
'a3',
'a4',
'a5'
}

I’m trying to make it so the end result will be something like

local finalized = {
[1] = {'w1', 'w2', 'w3', 'w4', 'w5'},
[2] = {'a1', 'a2', 'a3', 'a4', 'a5'}
}

Essentially, it reads though the array, and places 5 strings into the finalized array.
idk if im explaining this correctly but i also need it so i can have more than 5, 10, or an even number of strings in the exampletable

I’ve tried everything I can think of and I genuinely cannot find a damn fix for this. Wouldn’t be surprised if it was easy since it is midnight.

1 Like

I don’t really know if this will serve your purpose but here is the way I did it -

local t1  = { "w1","a4" , "w3" , "a5" , "a6" , "w7"} 
local f1 = {{}  , {}} 
for _ , v in pairs(t1) do
	if (string.match(v,"w")) then
		table.insert(f1[1] , v)  
	else
		table.insert(f1[2] , v)	
	end 
end

It adds all the strings with “w” to f1[1] and all strings with “a” f1[2].
Then if you go through the tables in f1 you will see that the first table has strings with w and f1[2] to has all strings with a.

my explanation skills are bad i guess, but the values inside the table will change. lets say the table limit is 5 each, i need to sort the table of strings into their own table (max of 5) which i’m too dumb and tired to do, ill try to do it again but idk how tbh i tried like 10 different ways lol