Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you make a sub of a substring? (Please answer!)

Asked by
qVoided 221 Moderation Voter
4 years ago

The question/title may be weird, but it makes sense.

For example:


";speed mattangeles544444 100" -- speed will be : string.sub(1,7) -- mattangeles544444 will be: string.sub(8,18) -- 100** will be: string.sub(19,22)

If you understand, please answer, as I will be grateful.

0
I don’t know what you’re trying to ask, do you want the string.sub() of the results of a string.sub()? aredanks 117 — 4y
0
This question is not so clear, I don't know what you're trying to ask? killerbrenden 1537 — 4y
0
this is not a requesting site. Sadwowow21 57 — 4y
0
Please provide a script, This is not a requesting site. Trading_Opportunity 191 — 4y
View all comments (5 more)
0
where is the ** coming from? why are you not counting the spaces or the ;? 1waffle1 2908 — 4y
0
I am not requesting a script, I am sorry for not making the question so clear. qVoided 221 — 4y
0
This question is hard to ask. qVoided 221 — 4y
0
"Please answer!" it doesn't matter how hard it is, this is NOT a requesting site. Sadwowow21 57 — 4y
0
This isn't a request. royaltoe 5144 — 4y

1 answer

Log in to vote
1
Answered by
RayCurse 1518 Moderation Voter
4 years ago
Edited 4 years ago

You can use string.match() with a capture pattern to retrieve the information from the command. For example, the command pattern might be the sequence of a semicolon, command name, player name, and numerical argument.

local testStr = ";speed mattangeles544444 100"
local pattern = "^;(%w+)%s+([%w_]+)%s+(%d+)$"
local command, player, arg = testStr:match(pattern)
Ad

Answer this question