Creating a kick command?

So I have this admin system, and this is how it works.

Let’s say I have this message:
":kick zcr breaking rules 5, 1, 4"
It takes the arguments “kick”, “zcr”, and “breaking”, or args 1, 2, and 3.

It uses string.split to get the arguments.
How could I get the full string “breaking rules 5, 1, 4”

A split string (=table) can be joined together using table.concat({"breaking", "rules", "5,", "1,", "4"}, " "). The first argument is the table and the second argument the delimiter, more specifically what to put between every element of the table. Another post on the DevForum describes table.concat with further detail.

IMO string.split isn’t the best way to go about this specifically because it splits things that you don’t want to split.

Instead, try using string.match(str, pattern, startpos?).
For example:

local message = ":kick zcr breaking rules 5, 1, 4"

local command, who, reason = string.match(message, "^:(%S+)%s+(%S+)%s+(.*)")
if command == nil then return end -- stop if the pattern wasn't matched
-- command = kick
-- who = zcr
-- reason = breaking rules 5, 1, 4

The pattern ^:(%S+)%s+(%S+)%s+(.*) means this:
^: beginning of the string
:: just a colon
%S: stands for anything that’s not whitespace (spaces etc.), the opposite of %s (space characters)
%S+: at least one of anything that’s not whitespace
(%S+): capture that as one of the return values
%s+ or just + (space plus): at least one space
.*: any amount of anything
and later (): the position of this match

Of course, the format of “colon at the start, word, word, rest of the message” won’t fit every use case.
So first look for the colon and first word, and let each command handle its arguments separately.

local message = ":kick zcr breaking rules 5, 1, 4"

local command, nextpos = string.match(message, "^:(%S+)%s+()")
-- command = kick
-- nextpos = 7

if command == nil then
	-- message did not begin with a colon
	-- or it began with a colon and a space
	return
	
elseif command == "kick" then
	local who, reason = string.match(message, "^(%S+)%s+(.*)", nextpos)
	-- who = zcr
	-- reason = breaking rules 5, 1, 4
	
else
	-- etc etc.
end