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 9003957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:47:25+00:00 2026-06-16T00:47:25+00:00

I want to remove the text between html tags and then display it in

  • 0

I want to remove the text between html tags and then display it in textBox2.
I need to get the start postion for “<” and “>” and then delete the tags and everything in between.
I dont want to use regex.

Here’s what i got so far

        string input = textBox1.Text;
        string output = textBox2.Text;
        string results;
        for (int i = 0; i < input.Length; i++)
        {
            if(input.IndexOf('<',i) !=-1 )
            {


            }
  • 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-16T00:47:26+00:00Added an answer on June 16, 2026 at 12:47 am

    This should do what you’re looking for. However, it won’t handle cases where there is malformed markup. So for example, if you were to enter the input string Hello < world, the output would be Hello.

    string input = textBox1.Text;
    StringBuilder output = new StringBuilder(input.Length);
    bool inATag = false;
    
    for (var i = 0; i < input.Length; i++) {
        if (!inATag && input[i] != '>' && input[i] != '<') {
            output.Append(input[i]);
        } else if (input[i] == '<') {
            inATag = true;
        } else if (input[i] == '>') {
            inATag = false;
        }
    }
    
    textBox2.Text = output.ToString();
    

    To explain a little more about what’s going on, I’m iterating through the input string one character at a time. If I find an opening <, I enter a state where I will not add any of the input to the output until I find the closing >.

    The way I’m generating the output string is by using a StringBuilder to do string concatenation, which improves performance over using just string output += input[i]. It is not recommended to simply use a string as your output variable type because every time you concatenate 2 strings together, it allocates a completely new and distinct string. Over time, this will impact performance. With a StringBuilder, only one string object will be allocated, and no new string objects are created with every iteration through the loop.

    Microsoft has written a good explanation of why to use a StringBuilder, but the general rule is that you should be using a StringBuilder any time you find yourself concatenating strings inside of a loop.

    Conversely, for situations where your input string is known to always be small, it is better to not use a StringBuilder. There is a penalty for creating a StringBuilder object that isn’t overcome if you’re only concatenating a small number of strings. For example, if you expect to only do 10 string concatenations it would be considered an anti-pattern to use a StringBuilder. However if you’re concatenating hundreds of strings, like you are in this example, it is a very good candidate for using a StringBuilder.

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

Sidebar

Related Questions

i have a label tag and i want to remove text between <label> </label>
for example : I want to remove all highlighted tags alt text http://shup.com/Shup/299976/110220132930-My-Desktop.png
I have some text that has HTML hyper-links in it. I want to remove
I want to remove all the text between (and including) two strings in all
I want to use the dom removeChild function in php to remove everything between
I have NSString like My name is. I want to remove text after coming
I have a gridview and sqldatasource. I want to remove the header text underline
I want to remove the element tag and want to preserve the text inside
I want to remove all the white spaces from a given text file. Is
I got some html text, which contains all kinds of html tags, such as

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.