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

Help with string manipulation?

So, I'm in the works of an admin of some sort. The work below is me attempting to get whats between the ";"'s of "str". The output only shows me "Name/Shortname:", and not the "net". There are no errors.

local str = "speed;net;41"

local t = string.find(str, ";")
if t then
	local strt = string.sub(str, t+1)
	local s = string.find(strt, ";")
	if s then
		print("Name/Shortname: "..string.sub(str, t+1, s-1))
	end
end

If you are able to help me, can you also please explain why this is happening? Thank you.

1 answer

✓ Accepted answer

You can use string.match(str, ";([^;]*);") to get the 'net'. You could also use string.match(str, ";(.*);") if you know there's only going to be two semicolons.

1 comment

0

Thank you.

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