I'm trying to match two tables by string case in sensitive.
Example
[6] =
{
["itemName"] = [Ore],
["cleanName"] = [[Iron Ingot]],
["secs"] = 25004,
["gN"] = [[Luminary]],
["buyer"] = [[@Naptha42]],
["eventType"] = 15,
["timestampz"] = 1399514069,
["quantity"] = 100,
["soldAmount"] = 500,
["seller"] = [[@FataI]],
},
I'm trying to move items from the above table format into a new table, or filter them into a list.
g = e.cleanName
for k, v in pairs(savedTable.ALL_ITEMS) do searchTable[k] = v
if g == savedTable.ALL_ITEMS.cleanName then
table.insert(searchTable, savedTable.ALL_ITEMS)
end
end
The problem above is g never = that savedTable.
The table has a few thousand entries and I'm trying to display by search, I believe the best way is to create a new table with the values im looking for?
Or is there a way to use the string.match to iterate through the table and display (print) only these values.
//Update
I have an active search, each time the user enters a letter it will search the table.
Example.
Val1 = "Hello"
Val2 = "Goodbye"
Val3 = "Hi"
While searching and the user enters "H" or "h" I want the results for "hello, hi" to show up but not "goodbye"
so with the if g == string.match(savedTable.ALL_ITEMS.cleanName)
not sure if that is correct.
//UPDATE for solution of what worked (thanks ESOUI)
local searchForItem = string.lower(g)
for k, v in ipairs(myTable.ALL_SALES) do
-- if string.lower(g) == string.lower(v.cleanName) then
if string.lower(v.cleanName):find(searchForItem) then
if v.cleanName ~= nil then
table.insert(searchTable, v)
end
end
end