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

How can I make a string pattern that works for this format?

Current Students:

AppleTreeFromNewYork

i have some text that looks like this, it can also look like this

Current Students:

AppleTreeFromNewYork,anotherstudent,thirdstudent

and i need a string pattern so i can get each student i have tried different ones to just get the 1 student but there can also be many students, this is the one i tried (.+)%s%s(.+) i just need help making a string pattern that can get all the students listed

1 comment

0

yes i know this is formatted terribly, sorry about it

1 answer

✓ Accepted answer

For such a string pattern, you can use custom char-sets [sic]. Specifically, we will use the circumflex ^ at the beginning of the char-set definition to make it exclusive:

local students = "AppleTreeFromNewYork,anotherstudent,thirdstudent"
for student in students:gmatch("[^,]+") do -- Match strings containing as many non-commas as possible
	print(student)
end

2 comments

0

the think is is that idk how to get the students

0

because it looks like "Current Students:\n\nAppleTreeFromNewYork,anotherstudent,thirdstudent" and this looks bad because i cant space right here

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