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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:45:36+00:00 2026-05-16T14:45:36+00:00

I have a text area in my ASP.NET web application that is used to

  • 0

I have a text area in my ASP.NET web application that is used to enter html code. Now there is also an button control, which upon clicking should retrieve just the text placed between certain html tags in the text box.

For example:

1) User types html code including tags etc. and clicks the OK button
2) In my code the text from the text area is retrieved and only the part between a <p></p> tag should be saved to a string object.

I can obviously get the text from the text area and attach it to a string object but I am not able to work out how to just get text within a certain html tag like <p></p>. Could someone help me out please?

  • 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-05-16T14:45:36+00:00Added an answer on May 16, 2026 at 2:45 pm

    Try this… example taken from MSDN and amended slightly to show your situation:

    using System;
    using System.Text.RegularExpressions;
    
    class Example 
    {
       static void Main() 
       {
          string text = "start <p>I want to capture this</p> end";
          string pat = @""<p>((?:.|\r|\n)+?)</p>"";
    
          // Instantiate the regular expression object.
          Regex r = new Regex(pat, RegexOptions.IgnoreCase);
    
          // Match the regular expression pattern against a text string.
          Match m = r.Match(text);
          int matchCount = 0;
          while (m.Success) 
          {
             Console.WriteLine("Match"+ (++matchCount));
             for (int i = 1; i <= 2; i++) 
             {
                Group g = m.Groups[i];
                Console.WriteLine("Group"+i+"='" + g + "'");
                CaptureCollection cc = g.Captures;
                for (int j = 0; j < cc.Count; j++) 
                {
                   Capture c = cc[j];
                   System.Console.WriteLine("Capture"+j+"='" + c + "', Position="+c.Index);
                }
             }
             m = m.NextMatch();
          }
       }
    }
    

    You can see this in action at ideone.com.

    If you want to include your <p> tags in the result, then just change where you put the brackets in the regular expression to this:

    string pat = @"(<p>(?:.|\r|\n)+?</p>)";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.Net application that is hosted on my corporate clients web servers
I have a web page that has an HTML table generated by an ASP.NET
Greetings, I have an asp.net mvc application. I have some links that corresponds to
I am working on an ASP.Net web application that must print dynamically created labels
I have an ASP.NET web site technology that I use for scores of clients.
I have a problem wherein if I have a text area in ASP.NET and
I have an asp.net application c# that uses session state to store a variable
I have an existing ASP.NET MVC 2 application that I've been asked to extend.
I am developing asp.net with c#web application. I want to have a control in
I have some text area field in my grails application. I got the following

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.