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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:48:31+00:00 2026-05-11T20:48:31+00:00

I have a string that should contain a list of items in the form

  • 0

I have a string that should contain a list of items in the form , {0}, {1}, and {2} are strings and I want to basically extract them.

I do want to do this for part of an html parsing problem, and I have heard that parsing html with regular expressions is bad. (Like here)

I am not even sure how to do this with regular expressions.

This is as far as I got

string format = "<link rel=\".*\" type=\".*\" href=\".*\">";
Regex reg = new Regex(format);
MatchCollection matches = reg.Matches(input, 0);
foreach (Match match in matches)
 {
        string rel = string.Empty;
        string type = string.Empty;
        string href = string.Empty;
        //not sure what to do here to get these values for each from the match
 }

Before my research turned up that I might be completely on the wrong track using regular expressions.

How would you do this either with the method I chose or with an HTML parser?

  • 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-11T20:48:31+00:00Added an answer on May 11, 2026 at 8:48 pm

    You’d be better off using a real HTML parser like the Html Agility Pack. You can get it here.

    A main reason for not using regular expressions for HTML parsing is because it might not be well-formed (almost always the case), which could break your regular expression parser.

    You would then use XPath to get the nodes you need and load them into variables.

    HtmlDocument htmlDoc = new HtmlDocument();
    htmlDoc.LoadHtml(pageMarkup);
    HtmlNodeCollection nodes = htmlDoc.DocumentNode.SelectNodes("//link");
    string rel;
    
    if(nodes[0].Attributes["rel"] != null)
    {
        rel = nodes[0].Attributes["rel"]; 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string that looks like this: 9/1/2009. I want to convert it
I have a list that contain two colums which are type currency. I want
I have one class called Holder (holder.cs) that contain the following: string name; List<String>
Hello I have a small List<string> that I want to maintain across postbacks on
I have a text column that should only have 1 of 3 possible strings.
i have a string that looks like this: sodjfoisdfsdf sdofij sodiosifosf fsdi a123 sdfoi
I have a string that contains a czech character. the string is 0bálka This
I have a string that I want passed via the linebreaks filter. {% trans
My Python server receives jobs that contain a list of the items to act
I have a a simple ordered list that could contain 1 million or more

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.