Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我用这个
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 }