关于c#的正则表达式 我想提取一个网页上所有类似这样的超链接地址,只有products_id的参数是可变的数字,请问这样的正则表达式该怎么写?<a href="http://bd238.com/product_info.php?products_id=3556">xxxxx</a> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string pattern=@"(?i)<a[^>]*?href=[""']?http://bd238\.com/product_info\.php?products_id=\d+[""']?[^>]*>[^<]*</a>"; (?is)<a.*?products_id=.*?</a> Regex RegUrl = new Regex("<a href.*bd238.*products_id=.*</a> ", RegexOptions.ExplicitCapture | RegexOptions.Multiline | RegexOptions.IgnoreCase);MatchCollection mCollection = Regs.RegUrlPostNext.Matches(页面源码);string WebUrl ;foreach (Match match in mCollection){ WebUrl = match.ToString(); WebUrl = WebUrl.Substring(WebUrl.LastIndexOf("href=\"") + 6); WebUrl = WebUrl.Substring(0, WebUrl.LastIndexOf("</a>") - 7).Trim();} <a[\s\S]+?href\s*=\s*(['"])?(http:\/\/bd238\.com\/product_info\.php\?products_id\s*=\s*([^>\s\n]+))\1 求XenoCode详细使用方法 用C#怎么把SESSION存储在IIS中? 关于运行时主窗体隐藏,显示登录窗体,登录成功后关闭登录窗体,显示主窗体。 winfrom的安装部署 怎样把系统必备也打包进去? 对一个已经启动的实例,进行操作 如何实现动态TreeView(100分) 请教大家! 在vs.net中如何察看控件的属性代码 寻求源码开放网站 程序设计采用三层或更多层有什么好处呢 使用Xml中的SelectNode和SelectSingleNode的发现 新手,请教大牛 。winfrom统计 xml文件
MatchCollection mCollection = Regs.RegUrlPostNext.Matches(页面源码);
string WebUrl ;
foreach (Match match in mCollection)
{
WebUrl = match.ToString();
WebUrl = WebUrl.Substring(WebUrl.LastIndexOf("href=\"") + 6);
WebUrl = WebUrl.Substring(0, WebUrl.LastIndexOf("</a>") - 7).Trim();
}
<a[\s\S]+?href\s*=\s*(['"])?(http:\/\/bd238\.com\/product_info\.php\?products_id\s*=\s*([^>\s\n]+))\1