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

How do you split a string into multiple words?

Asked by
iiKind 13
6 years ago

For example, ":speed iiKind 100", how would you split it into multiple words? Would you use string.sub()? string.find()? etc?

0
string.sub my friend User#19524 175 — 6y
0
don't use string.sub, i tried that once and it was a pain, just use string.match hiimgoodpack 2009 — 6y
0
STRING MANIPULATIONNNNNNNNNNNNNNNNNNNNNNnnn greatneil80 2647 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

You can use string.gmatch() for it :

local str = ":speed iiKind 100"

for word in string.gmatch(str, "[^ ]+") do
    print(word)
end

https://www.robloxdev.com/articles/string-patterns-reference

Ad

Answer this question