Reputation: 53301
I'm looking to remove the all parentheses from a given string. After some research, I've come to the conclusion that Regex was my best bet. However, looking at it (let alone looking at it, thinking about looking at it) gives me a headache. What would be the best way to approach this problem?
Upvotes: 5
Views: 14392
Reputation: 39017
Your question isn't very clear, or is very trivial.
Why not use String.Replace('(', '').Replace(')','')
?
If you must use a regex, this is the link for how you would use a Regex.Replace
Upvotes: 1
Reputation: 39197
The following statement removes all characters (
and )
.
Regex.Replace("This (is (a) (test.", "[()]", "") // -> "This is a test."
Upvotes: 15