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

How do you "invert string.gmatch?"

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

✓ Accepted answer
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

2 comments

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

0

That string is called a "pattern": http://wiki.roblox.com/index.php?title=String_pattern

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