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
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