获取字符串中img标签的url集合(转载)

时间:2024-01-14 18:56:32
/// <summary>
/// 获取字符串中img的url集合
/// </summary>
/// <param name="content">字符串</param>
/// <returns></returns>
public static List<string> GetImgUrl(string content)
{
Regex rg = new Regex("src=\"([^\"]+)\"", RegexOptions.IgnoreCase);
var img = rg.Match(content);
List<string> imgUrl = new List<string>();
while (img.Success)
{
imgUrl.Add(img.Groups[].Value);
img = img.NextMatch();
}
return imgUrl;
}

忘记是从哪里弄的代码了,原作者看见留言一下,我会加上地址的