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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:48:00+00:00 2026-05-14T21:48:00+00:00

I have this html: <a href=http://www.site.com/>This is the content.</a> I just need to get

  • 0

I have this html:

<a href="http://www.site.com/">This is the content.</a>

I just need to get rid of the anchor tag html around the content text, so that all I end up with is “This is the content”.

Can I do this using Regex.Replace?

  • 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-14T21:48:00+00:00Added an answer on May 14, 2026 at 9:48 pm

    Your regex: <a[^>]+?>(.*?)</a>

    Check this Regex with the Regex-class and iterate through the result collection
    and you should get your inner text.

    String text = "<a href=\"link.php\">test</a>";
    
    Regex rx = new Regex("<a[^>]+?>(.*?)</a>");
    // Find matches.
    MatchCollection matches = rx.Matches(text);
    
    // Report the number of matches found.
    Console.WriteLine("{0} matches found. \n", matches.Count);
    
    // Report on each match.
    foreach (Match match in matches)
    {
        Console.WriteLine(match.Value);
    
        Console.WriteLine("Groups:");
        foreach (var g in match.Groups)
        {
            Console.WriteLine(g.ToString());
        }
    }
    
    Console.ReadLine();
    

    Output:

      1 matches found. 
      <a href=\"link.php\">test</a> 
      Groups:
      <a href=\"link.php\">test</a> 
      test
    

    The match expression in () is stored in the second item of match‘s Groups collection (the first item is the whole match itself). Each expression in () gets into the Groups collection. See the MSDN for further information.

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

Sidebar

Related Questions

I have some HTML like this: <h4 class=box_header clearfix> <span> <a rel=dialog href=http://www.google.com/?q=word>Search</a> </span>
I have downloaded the jquery scroll script (http://www.position-absolute.com/articles/better-html-anchor-a-jquery-script-to-slide-the-scrollbar/) which will scroll to your anchor
I have that code var p = document.createElement('p'); var a = document.createElement('a'); $(a).attr('href', 'http://www.my-site.com');
I have the following site: http://www.pachamber.org/www/advocacy/index.php When a user clicks the 'General Commerce' href
Suppose I have: <a href=http://www.yahoo.com/ target=_yahoo title=Yahoo!&#8482; onclick=return gateway(this);>Yahoo!</a> <script type=text/javascript> function gateway(lnk) {
I have this xml. <?xml version=1.0 encoding=utf-8?> <feed xml:lang=el-gr xmlns=http://www.w3.org/2005/Atom> <title type=text>name.gr</title> <updated>2011-07-23</updated> <link
Let's say I have this in a document: <entry> <link rel=replies type=application/atom+xml href=http://www.url.com/feeds/1/comments/default title=Comments/>
<html xmlns=http://www.w3.org/1999/xhtml xmlns:h=http://java.sun.com/jsf/html xmlns:ui=http://java.sun.com/jsf/facelets> <h:body> <title><ui:define name=title>Page 2</ui:define></title> <ui:composition template=template/common/commonLayout.xhtml> <ui:define name=content> This is
This is a strange problem. I have two html pop-up windows, just hidden divs
I have this HTML structure and want to convert it to an accordion. <div

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.