So I am developing an admin script and currently I am working on making it so you can do a command on multiple players are the same time by separating them with commas, for that I am using string.gmatch to find the comma and then removing it with string.gsub. The problem is though, that I cannot get string.gmatch to work with punctuation (including commas), is there a way round this?
You would’ve needed to actually post the code used because it’s most likely a problem on your end.
Anyway, I got this to work only using gmatch:
local str = "apple, banana, orange, potato"
for s in str:gmatch("[^,%s]+") do
print(s)
end
Output:
3 Likes
Yeah, %w isn’t the best approach here because players’ usernames can have underscores. The issue you were having was probably that it was only matching one though
3 Likes
The code: for stringChar in string.gmatch(arg, "(%w)") do
Ok thanks so much, it works, I’ve been trying to find a solution for hours.
