c# c#正则表达式 取指定<img 的src c# c#正则表达式 取指定<img id=id="lens_img" 的图片连接地址 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 (?is)<img[^>]*?id="lens_img"[^>]*?href=(["']?)(?<href>[^"']*?)\1[^>]*?/>取Groups["href"].Value string str = "<img id=\"lens_img\" src=\"1.jpg\">"; var result = Regex.Match(str, @"(?i)<img[^>]*?id=(['""]?)lens_img\1[^>]*?src=(['""]?)(?<src>[^'""]+?)\2[^>]*?>").Groups["src"].Value; //1.jpg 给你段提取html元素的img标签的连接地址代码希望对你有用public static string[] GetHtmlImageUrlList(string sHtmlText) { // 定义正则表达式用来匹配 img 标签 Regex regImg = new Regex(@"<img\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<src>[^\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["src"].Value; return sUrlList; } .net 调用delphi 写的dll,出错误尝试读取或写入受保护的内存。这通常指示其他内存已损坏。 为防吝啬老板,怎样定期销毁系统 .NET获取硬盘序列号的方法总结,希望大家一起评下。 ”确保已安装项目类型(.etp)的应用程序!“这个怎么处理?谢谢 .NET安装是不是跟系统也有关系的呀 C#中使用Bitmap造成资源泄漏问题 c# form问题~? WCF与网站的通信 求一本C#的GUI编程的好书 續:對text字段進行匯總 请教:C#中如何获取其它窗口(比如记事本的字体设置窗口)中每一个控件的句柄以及设置ComboLBox的选中项? KeyPress事件的问题
取Groups["href"].Value
//1.jpg
给你段提取html元素的img标签的连接地址代码希望对你有用public static string[] GetHtmlImageUrlList(string sHtmlText)
{ // 定义正则表达式用来匹配 img 标签 Regex regImg = new Regex(@"<img\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<src>[^\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["src"].Value; return sUrlList; }