I’m trying to pattern match the following and substitute “c” for both a left and right parenthesis.
Example:
string = “(a,b)”
So I want the string to come out like “ca,cb” after I call string.sub(//,"c") on it. I’ve tried string.sub(/[()]/,"c"), but that only results in “ca,b)”. How do I pattern match the left AND right parenthesis?
Note the
gsub:submakes a single substitution;gsub(“global sub”) substitutes as many as it can.