我用这个
string matchString = Regex.Match(sometext, "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase).Groups[1].Value;
获取图像 src。
但是我怎样才能得到我能找到的所有 src 呢?
谢谢!
最佳答案
您应该使用 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
}
关于c# - 如何获取某些 html 的所有图像 src,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10538737/