I have a string where I want to replace all chars and digits with "", except chars a,b,c, d.
Instead of having to write multiple lines of long code like in the example below, is there some other way to write this more efficient?
myString:gsub("[%(%)%.%%%+%-%*%?%[%]%^%$%,]", "") --special chars
... --same for chars
... --same for digits
Use caret symbol ^
That is, [^abcd]
Caret symbol negates your set.
E.g., you can read it more carefully here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With