//JavaScript中的代码: var re = /src=\"([^\"]*?)\"/i; var arr = str.match(re); if (arr != undefined && arr.length > 0) { insertHtml = arr[1]; }
/// <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 m = rg.Match(content); List<string> imgUrl = new List<string>(); while (m.Success) { imgUrl.Add(m.Groups[1].Value); //这里就是图片路径 m = m.NextMatch(); } return imgUrl; }