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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:57:59+00:00 2026-06-15T02:57:59+00:00

I have the following html, i tried many many regex to remove hperlink content/text

  • 0

I have the following html, i tried many many regex to remove hperlink content/text that is between ul tag and li tag only, but not found any regex for removing a tag text . I want that , whenever a tag comes under in ul and li tag then i want to replace a tag text with empty string.

<ul id="foot.dir" class="content" >
 <li><a href="http://www.citysearch.com/aboutcitysearch/about_us"  name="search_grid.footer.1.aboutCs" rel="nofollow" id="foot.dir.about">About</a></li>
 <li><a href="http://www.citysearch.com/mobile-application" name="search_grid.footer.1.mobile" id="foot.dir.apps">Apps</a></li>
</ul>

i have tried this regex but it is not working, here input is string that contains html.

input = Regex.Replace(input, @"<ul[^>]*?><li><a[^>]*?>(?<option>.*?)</ul></li></a>", string.Empty);

Please help me out. Thank You

  • 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-15T02:58:00+00:00Added an answer on June 15, 2026 at 2:58 am

    Regex is not a good choice for parsing HTML files..

    HTML is not strict nor is it regular with its format..

    Use htmlagilitypack

    Regex is used for Regular expression

    You can use this code to retrieve it using HtmlAgilityPack

    HtmlDocument doc = new HtmlDocument();
    doc.Load(yourStream);
    
    foreach(var item in doc.DocumentNode.SelectNodes("//li[a]"))// select li only if it has anchor tag
    {
        item.ParentNode.RemoveChild(item);//removed anchor tag
    }
    //dont forget to save
    

    i want to remove tag text using regex only ..

    Regex.Replace(input,@"(?<=<li[^>]*>)\s*<a.*?(?=</li>)","",RegexOptions.Singleline);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following string , i tried many many regex to remove comma
I have tried following many articles and used many links in SO but I
I have the following HTML page and the background color for the content is
I have the following html to parse: <h1 class=x>test</h1> <p>some text <img src=x /></p>
I have a HUGE html which has many things I don't need, but inside
I have the following simple Javascript code that allows only digits to be entered
I have following html file (1.html) and once I open it in my browser
I have following HTML: <div class=olympics style=display: block; position: absolute; left: 250px; top: px;>
I have following HTML <tr id=r1 class=l1> <td><img class=plusminus id=r1c1 src=assets/images/plus.png border=0 />3/10/12</td> <td></td>
I have the following html table <table id={64ED3A94-5833-4CC7-869F-CCE583B498BE} class=ms-listviewtable width=100% cellspacing=0 cellpadding=1 border=0 xmlns:o=urn:schemas-microsoft-com:office:office

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.