I'm using this pattern: [^, ]+
Code:
function split(str) local strs = {} for someStr in str:gmatch("[^, ]+") do table.insert(strs, someStr) end return strs end print(unpack(split("123, lol, hi, oof, foo, bar, var")))
Seems okay right? But when I was testing, I pressed play, but missed a comma:
print(unpack(split("a, s d")))
And results?
a s d
The pattern is supposed to only get chunks of strings with a comma, but between s and d, there's no comma. I thought it'll be
a s
But apparently, no. Is there anything I can do to prevent that?