How can I get the number of times an enttry in a table was listed

Keywords´╝Ü lua lua-table roblox


I need to find a way to see how many times an entry is listed in a table.

I have tried looking at other code for help, and looking at examples online none of them help

local pattern = "(.+)%s?-%s?(.+)"

local table = {"Cald_fan:1", "SomePerson:2", "Cald_fan:3","anotherPerson:4"}

for i,v in pairs(table) do
    local UserId, t = string.match(v, pattern)

    for i,v in next,UserId do
        --I have tried something like this

it is suppose to say Cald_fan was listed 2 times