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

protected string[] GetSrc(string str)
    {
        string regStr = " \\[^'\" \\>\\ ]+)['\" \\>\\ ]";
        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/archive/2011/03/04/1970858.html

你可能感兴趣的:(获取字符串中img标签中src的数组列表)