I have several strings that look like this:
\"((String1))\"
They are all different lengths. How could I remove the parentheses from all these s
Here is an even shorter way of achieving this:
1) using Negative character class pattern matching
irb(main)> "((String1))"[/[^()]+/]
=> "String1"
^
- Matches anything NOT in the character class. Inside the charachter class, we have (
and )
Or with global substitution "AKA: gsub" like others have mentioned.
irb(main)> "((String1))".gsub(/[)(]/, '')
=> "String1"