How to check if a string contains any string from a table

for example:

if a table contains 10 strings and a string contains any word from that table, and i mean if it contains it as in the word is anywhere in the string

i’ve looked everywhere but the only ones i found were specific strings from a table

1 Like

You can do something like this:

local validStrings = {
	'str',
	'ing',
	'exa',
	'mple'
}

local function checkIfContains(toCheck)
	for _, v in validStrings do
		if toCheck:find(v) then
			return true
		end
	end
	
	return false
end

print(checkIfContains('string')) --will return true
print(checkIfContains('12345')) --will return false

thank you!

one question though, would i do this to check if text contains the validstrings and then do something about it?

	if checkIfContains(text) == true then
		-- do stuff
	end

Exactly!

(character limit lol)…

thank you so much!

(character limit too lol)

1 Like

after finding the string how can you change it Im trying to find string in table with getting info from remote event I tried table.find and it cant find it