4

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!

NoWar
  • 34,755
  • 78
  • 302
  • 475

1 Answers1

12

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
}
urraka
  • 987
  • 7
  • 9