title: RegEx to get href and src from HTML content?
body: <p>I am trying to extract href and src links from an HTML string. <a href="https://stackoverflow.com/questions/138839/how-do-you-parse-a-html-string-for-image-tags-to-get-at-the-src-information">According to this post</a>, I was able to get the image portion. Can anyone help adjust the regular expression to include the href URL in the collection too?</p>
  
  <pre><code>public List&lt;string&gt; GetLinksFromHtml(string content)
  {
      string regex = @"&lt;img[^&gt;]*?src\s*=\s*[""']?([^'"" &gt;]+?)[ '""][^&gt;]*?&gt;";
      var matches = Regex.Matches(content, regex, RegexOptions.IgnoreCase | RegexOptions.Singleline);
      var links = new List&lt;string&gt;();
  
      foreach (Match item in matches)
      {
          string link = item.Groups[1].Value;
          links.Add(link);
      }
  
      return links;
  }
  </code></pre>