1.) Is there a way to count how many operators there are in a given string? I’m only dealing with “+” if that matters.
2.) Also, just as important, how can I clean out all unwanted character(s)? Does the following look possible?
str = string.gsub(str, “%s+”, “”) – all space characters
str = string.gsub(str, “%a+”, “”) – all letters
str = string.gsub(str, “%p+”, “”) – all punctuation
Is there a way to combine these? For instance:
str = string.gsub(str, “%s+” or “%a+” or “%p+” , “”)
Or is there an easier way to go about cleaning out my string since all I’m concerned about are digits and the “+” operator by using the “.” character class to represent all characters (and then specify out the digits and operator).
Thanks very much in advance!