C# remove parenthesis from string

A Regex is overkill here as this can be done with a simple Replace call:

string val = intVal.Replace("(", "").Replace(")", "");

After your call to Regex.Replace(...) you're actually using string.Replace(...). This makes your call to .Replace(@"[^a-zA-Z]", "") useless.

Simplify it instead to:

cleanValue = Regex.Replace(intVal, @"[^a-zA-Z]", "");

This should remove all spaces and special characters which is what it looks like your code is trying to do. This includes parentheses.


That is because every second Replace is a call on a string and therefore doesn't replace with regex.