Detect a spacing or random caps word

as the topic said
i want to know how to detect a spacing or random caps word
Example: “test”
for what ive tried so far it only detect “test” instead of “tEsT” or “t es t”
are there a way to detect those?

One approach is to convert the input string to lowercase and remove all whitespace, then compare it with the lowercase version of the target word.

1 Like

OK, here’s an idea:

Detecting words case-insensitively is pretty straightforward. All you have to do is convert the text to lowercase with :lower().

E.g.

local source = "fOo Ba R"

local lowered = source:lower() -- "foo ba r"

local match = lowered:match("foo") -- Matches!

As for ignoring spaces, one idea is to just remove them entirely.

E.g.

local source = "fOo Ba R"

local lowered = source:lower() -- "foo ba r"

local nowhitespace = lowered:gsub(" ", "")

local match = nowhitespace:match("bar") -- Matches!

Be careful of false positives though, example is

best estimate would match the “t est”.

thats actually pretty smart ima try that