我用这个
string matchString = Regex.Match(sometext, "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase).Groups[1].Value;
Run Code Online (Sandbox Code Playgroud)
得到一个图像src.
但是我怎样才能得到所有我能找到的src?
谢谢!
urr*_*aka 10
你应该使用Regex.Matches而不是Match,你应该添加我相信的Multiline选项:
foreach (Match m in Regex.Matches(sometext, "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase | RegexOptions.Multiline))
{
string src = m.Groups[1].Value;
// add src to some array
}
Run Code Online (Sandbox Code Playgroud)