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

  • Home
  • SEARCH
  • 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 8481857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:40:30+00:00 2026-06-10T19:40:30+00:00

I am getting input from a text file. I have read all the text

  • 0

I am getting input from a text file. I have read all the text and tokenized it.

Here is input sample

.MAIN [
    .HEADING1 [ .TEXT 30000 ]
    .HEADING2 [
      [
        .TEXT1 YAMA
        .TEXT2 THAH
      ]
    ]
  ]

After tokenization, tokens list contains “.MAIN”, “[“, “.HEADING1”, and so on. Now what I want to find index of closing bracket for a particular starting square bracket. For example if i give my function index 0 (the first starting square bracket) function should return me last index, and if give my function index of starting square bracket of .HEADING1 then it should return me index of closing bracket at same line.

  • 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-10T19:40:31+00:00Added an answer on June 10, 2026 at 7:40 pm

    Try this one:

            //Give it index of first bracket you want
            int myStartingIndex = 0;
            string s = "[ sfafa sf [fasfasfas ] [ test ] ]";
            int firstClosedIndex = s.IndexOf("]", myStartingIndex + 1);
            int firstOpenedIndex = s.IndexOf("[", myStartingIndex + 1);
            while (firstOpenedIndex < firstClosedIndex)
            {
                firstClosedIndex = s.IndexOf("]", firstClosedIndex + 1);
                firstOpenedIndex = s.IndexOf("[", firstOpenedIndex + 1);
    
                //Break if there is no any opened bracket
                //index before closing index
                if (firstOpenedIndex == -1)
                {
                    break;
                }
            }
    
            Console.WriteLine("Required index is {0}", firstClosedIndex);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have as input text a big html file from where I have to
When I input locations from a txt file I am getting a peculiar error
Here's the scenario: I have a contact form with few checkboxes: <input type=text name=cola[]
I am designed a dynamic table for getting input from user. Each column of
I'm having some trouble with getting input from the command line before opening a
I'm using ncurses for simple UI that involves getting input from the user. The
The above emulator image is just getting the input from the user and showing
i have one text field and setting its name & values from php, like:
I have created two simple files in php. first file (i.e. input.php ): Created
my application geting Text from a input field an post it over ajax to

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.