That’s what I’m trying to figure out - I’ve already done only the words, and I’ve already done only the punctuation. Technically I could do words and then punctuation, but they need to be in order.
Here’s words -
[lua]
– str is any string
for w in str:gmatch("[%w_]+") do
print(w)
end
[/lua]
And here’s non-words -
[lua]
for w in str:gmatch("%A") do
print(w)
end
[/lua]
But if I do a table.insert for that, it’s not in order - “ABC…def…GHI!!!” results in “ABC” “def” “GHI” “.” “.” “.” “.” “.” “.” “!” “!” “!”
Does anyone know how to do it in order?
It would appear that there might be an “or” character for gmatch, but I’ve not found it. If there were an “or” character, you could just check for a word or a non-word.
Thanks!
Caleb