获取字符串中img标签中src的数组列表

protected string[] GetSrc(string str)
    {
        string regStr = "\\<IMG\\ [\\s\\S]*?src=['\"]?(?<p>[^'\"\\>\\ ]+)['\"\\>\\ ]";
        string cont1 = string.Empty; //图片的src
        Regex reg = new Regex(regStr, RegexOptions.Compiled | RegexOptions.IgnoreCase);
        Match match = reg.Match(str);
        string picSrc = "";
        while (match.Success)
        {
            picSrc = match.Groups["p"].Value;
            cont1 += string.Format("{0}", picSrc + ",");
            match = match.NextMatch();
        }
        cont1 = cont1.Substring(0, cont1.LastIndexOf(','));
        string[] strList = cont1.Split(',');
        return strList;
    }
原文地址:https://www.cnblogs.com/yhdkzy/p/1970858.html