How to search through a string for usernames

ok so ik ur gonna say:
just use table.find and make a table of the names u wanna find
but thats not what im trying to do, what i wanna do is search through a list with names i dont know and with varying lengths but with commas in between them so how would i do that?

example:

local names = "jdoasdo, mjnasdc0, do56tfs4ndasc"

--find their names in the STRING, NOT TABLE

I mean presumably, using a string split function (apparently Lua doesn’t have an inbuilt one, so give StackOverflow a search for one) and only then use table.find? I have to be honest - I’m not entirely sure on what the issue is

I wonder if string.find would work for this

I think this is what you want to do?

local YourTable = {"cool","boy"|,"Epicboy"} 
for i,v in pairs (YourTable) do
   if v == "TheUsername" then
          -- Do stufff
   end
end

uhh do u know how i can put code on devforum with the code format

Triple backticks (`) for codeblocks, start and end

Lua has a string.split() function.

1 Like

Huh - Google said otherwise (or maybe I just looked at an older version of Lua)

local s = "name,othername, bob"

local I, ii = string.find(s,"bob") -- finds thing

local sub = string.sub(s,I,ii)
print (sub) --prints it

Would this work