Extract first image src from HTML code

public static string ExtractFirstImageFromHtml(string text) 
{
  MatchCollection matches = Regex.Matches(text, "]* src=\"([^\"]*)?\"[^>]*>",RegexOptions.IgnoreCase); 
  string src = ""; 
  if (matches.Count > 0) 
  {
    src = matches[0].Groups[1].Value; 
  }
  return src; 
}
Advertisements