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

How can I split a string into 2 separate strings?

So pretty much, I need to know how to seperate stuff like this

table = {
	users = {
		"username:password"
	}
}


and just from that, you can print like print('username is username") print('password is password')

1 answer

For one you can make better data structure so you don't have to manipulate strings. There are multiple answers here but patterns are my favorite.

--gets as few characters as possible until colon, then the rest
--parentheses 'capture' matches to give to variables
local user,pass = str:match("(.-):(.+)")

print(user,pass)

Learn more

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