I want to find out of to do this. I know to remove all punctuation, you can do string:gsub("%p", ""), but how do I do that to everything other then commas, question marks, and exclamation points.
Assuming you want to keep non-punctuation characters (alphanumerics and whitespaces) you’d do the following.
local strings = ",<>a b c<>?<>1 2 3<>!"
strings = strings:gsub("[^%w%s,?!]", "")
print(strings) --,a b c?1 2 3!
If you want to remove all characters but the three mentioned you’d do the following.
local strings = ",<>a b c<>?<>1 2 3<>!"
strings = strings:gsub("[^,?!]", "")
print(strings) --,?!