ERROR malformed pattern (missing ']') when using string.find()

I am making a custom chatbox that finds matches when a player is typing in a command. For example if they type /m it will match that string to both /me and /money and /monkeys, for example.

I thought that it might have been the slashes causing this, but I’ve even tried to sub versions of the strings without the slash and do my comparison based on that. I still get the error on whatever line the string.find is taking place.

Here is some code, the last line is what the error is pointing to:

					local noslash_msgTypedSoFar = string.sub( msgTypedSoFar, 2 )
					local noslash_strCommand = string.sub( v.strCommand, 2 )
					local strFound = string.find( noslash_msgTypedSoFar, noslash_strCommand )

Here’s the error (with file and line omitted):

malformed pattern (missing ']')

Any help would be appreciated. Thank you!

Try to set the noPatterns argument to true with the string.find - Garry's Mod Wiki function, maybe that will fix your issue.

Thank you so much!