How to get all Images src's of some html

c#, image, regex

Solution

You should use Regex.Matches instead of Match, and you should add the Multiline option I believe:

foreach (Match m in Regex.Matches(sometext, "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase | RegexOptions.Multiline))
{
    string src = m.Groups[1].Value;
    // add src to some array
}

Problem

I use this ``` string matchString = Regex.Match(sometext, "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase).Groups[1].Value; ``` to get an images src. But how do I can get all src what I can find? Thanks!

Original source