本文共 656 字,大约阅读时间需要 2 分钟。
- public static string[] GetHtmlImageUrlList(string sHtmlText)
- {
-
- Regex regImg = new Regex(@"<img\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>", RegexOptions.IgnoreCase);
-
-
- MatchCollection matches = regImg.Matches(sHtmlText);
- int i = 0;
- string[] sUrlList = new string[matches.Count];
-
-
- foreach (Match match in matches)
- sUrlList[i++] = match.Groups["imgUrl"].Value;
- return sUrlList;
- }
转载于:https://www.cnblogs.com/wahaccp/p/3989063.html