Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8293781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:57:09+00:00 2026-06-08T13:57:09+00:00

I am wondering what would be the best way to specify an array of

  • 0

I am wondering what would be the best way to specify an array of characters like,

{
}
[
]

and then check a string for these and if they are there, to completely remove them.

        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[]
        {
            "'",
            "&"
        };

        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 > (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();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:57:10+00:00Added an answer on June 8, 2026 at 1:57 pm

    A regular expression can do this far more easily:

    var result = Regex.Replace(input, @"[[\]()]", "");
    

    Using a character set ([...]) to match anyone of the characters in it and replace with nothing. Regex.Replace will replace all matches.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering what would be the best way to accomplish something like this...
I'm wondering what would be the best way to check if a file is
i was wondering what would be the best way to code a browser plugin
I recently started learning backbone and was wondering what would be the best way
I was wondering, what would be the best way to validate an integer. I'd
I've been wondering what the best way to do this would be. I've got
Wondering what the best / good way of doing this would be in jQuery.
I am wondering what would be the best way to empty the content of
I'm wondering what would be the best way to group contacts by their company.
I'm wondering what would be the best way to store math constants that are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.