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

How do you "invert string.gmatch?"

Asked by 6 years ago
local example = "name | userid"
for i in string.gmatch(example, " | ") do
    print(i)
end

I'm trying to split name, and userid into separate strings, but the script above cuts out everything BUT the " | " when I want it to split on that, so how can I basically invert this?

1 answer

Log in to vote
0
Answered by 6 years ago
local ID = "ID,ID,ID";
for i in string.gmatch(ID, "[^,^]+") do
print(i) -- You can get the name by using a async called game.Players:GetNameFromUserIdAsync()
end
0
That wasn't really what I asked for, but I was able to figure it out using your "format" or whatever you'd call the "[^,^]+" thing, thanks User#1007 6 — 6y
0
That string is called a "pattern": http://wiki.roblox.com/index.php?title=String_pattern WillieTehWierdo200 966 — 6y
Ad

Answer this question