What in the world does this code mean?

Im mainly confused on the text inside the match function, I looked on the wiki and could not find anything. Can anyone give me a explanation to what the characters mean?

The function string.match() takes a pattern string. Lua uses its own string patterns instead of Regex. You can read more in the official docs.

That pattern looks like it matches a string that begins with (^) any string of any characters (.+) that might be followed by any or no (*) space characters (%s) before ending ($).

It seems pretty useless because (.+) will match everything?

2 Likes

Since only the .+ is captured using the () then this pattern is actually a tokenizer matching every word and throwing out whitespace.

2 Likes