title: Checking for and removing any characters in a string
body: <p>I am wondering what would be the best way to specify an array of characters like,</p>
  
  <pre><code>{
  }
  [
  ]
  </code></pre>
  
  <p>and then check a string for these and if they are there, to completely remove them.</p>
  
  <pre><code>        if (compiler.Parser.GetErrors().Count == 0)
          {
              AstNode root = compiler.Parse(phrase.ToLower());
              if (compiler.Parser.GetErrors().Count == 0)
              {
                  try
                  {
                      fTextSearch = SearchGrammar.ConvertQuery(root, SearchGrammar.TermType.Inflectional);
                  }
                  catch
                  {
                      fTextSearch = phrase;
                  }
              }
              else
              {
                  fTextSearch = phrase;
              }
          }
          else
          {
              fTextSearch = phrase;
          }
  
          string[] brackets = brackets = new string[]
          {
              "{",
              "}",
              "[",
              "]"
          };
  
          string[] errorChars = errorChars = new string[]
          {
              "'",
              "&amp;"
          };
  
          StringBuilder sb = new StringBuilder();
  
          string[] splitString = fTextSearch.Split(errorChars, StringSplitOptions.None);
  
          int numNewCharactersAdded = 0;
          foreach (string itm in splitString)
          {
              sb.Append(itm); //append string
              if (fTextSearch.Length &gt; (sb.Length - numNewCharactersAdded))
              {
                  sb.Append(fTextSearch[sb.Length - numNewCharactersAdded]); //append splitting character
                  sb.Append(fTextSearch[sb.Length - numNewCharactersAdded - 1]); //append it again
                  numNewCharactersAdded++;
              }
          }
  
          string newString = sb.ToString();
  </code></pre>