utilizing string.lower to work with tables

I have a code to hide ulx commands popping up in the chat, and I wanted to use string.lower instead of string.sub (For obvious reasons)
I have this:


local function hidechat( ply, text, public )
	for k, v in pairs(ulx_commands_table) do
		if string.lower( text, 1, #v ) == v then
			return("")
		end
	end
end

hook.Add("PlayerSay", "hidechat", hidechat)

But for some reason, it isn’t working. So I added a string.sub part:


local function hidechat( ply, text, public )
	for k, v in pairs(ulx_commands_table) do
		if string.lower( text, 1, #v ) == v then
			return("")
		end
	end
end

local function hidechatdebug( ply, text, public )
	for k, v in pairs(ulx_commands_table) do
		if string.sub( text, 1, #v ) == v then
			return("")
		end
	end
end

hook.Add("PlayerSay", "hidechat", hidechat)
hook.Add("PlayerSay", "hidechatdebug", hidechatdebug)

Now it works if I type (for example) !slap but not !sLaP.
Am I doing something wrong with string.lower?

Untested.



local function doCrap(_, text)
  text = text:lower()
  for _, cmd in pairs(ulx_commands_table) do
    if text:StartWith(cmd) then return "" end
  end
end
hook.Add("PlayerSay", "HideUlxCommands", doCrap)