Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

9 comments

0

I don’t know what you’re trying to ask, do you want the string.sub() of the results of a string.sub()?

0

This question is not so clear, I don't know what you're trying to ask?

0

this is not a requesting site.

0

Please provide a script, This is not a requesting site.

0

where is the ** coming from? why are you not counting the spaces or the ;?

0

I am not requesting a script, I am sorry for not making the question so clear.

0

This question is hard to ask.

0

"Please answer!" it doesn't matter how hard it is, this is NOT a requesting site.

0

This isn't a request.

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.