title: C# remove parenthesis from string
body: <p>This seems to be a common question for C# users and after research and multiple attempts I cant for the life of me remove a pair of parenthesis from a string. The string I am having a problem with is <code>Service (additional)</code>.</p>
  
  <p>After doing my research I understand parenthesis are treated differently in <code>Regex.Replace</code>. With my research also came multiple answers that I attempted but nothing seems to have worked. Here are some ways that I have tried to remove these parenthesis.</p>
  
  <pre><code>cleanValue = Regex.Replace(intVal, " ", "").Replace("(", "").Replace(")", "").Replace(",", "").Replace("/", "").Replace("-", "");
  
  cleanValue = Regex.Replace(intVal, " ", "").Replace(@"\(", "").Replace(@"\)", "").Replace(",", "").Replace("/", "").Replace("-", "");
  
  cleanValue = Regex.Replace(intVal, " ", "").Replace("[()]", "").Replace(",", "").Replace("/", "").Replace("-", "");
  
  cleanValue = Regex.Replace(intVal, " ", "").Replace(@"[^a-zA-Z]", "").Replace(",", "").Replace("/", "").Replace("-", "");
  </code></pre>
  
  <p>None of these worked, after stepping through the code I just see the the space between the 'e' and '(' removed. Am I missing something?</p>
  
  <p>In case anyone wanted to see the <code>function</code> that is being used here it is:</p>
  
  <pre><code>    public static string CleanExtra(string intVal)
      {
          string cleanValue;
          if (intVal == null)
          {
              throw new System.ArgumentException("Value cannot be null", "original");
          }
          else
          {
              //cleanValue = Regex.Replace(intVal, " ", "").Replace("(", "").Replace(")", "").Replace(",", "").Replace("/", "").Replace("-", "");
              //cleanValue = Regex.Replace(intVal, " ", "").Replace(@"\(", "").Replace(@"\)", "").Replace(",", "").Replace("/", "").Replace("-", "");
              //cleanValue = Regex.Replace(intVal, " ", "").Replace("[()]", "").Replace(",", "").Replace("/", "").Replace("-", "");
              cleanValue = Regex.Replace(intVal, " ", "").Replace(@"[^a-zA-Z]", "").Replace(",", "").Replace("/", "").Replace("-", "");
          }
  
          return cleanValue;
      }
  </code></pre>