我想取出网页源代码中所有以"http://www.home160.net"开头的链接,正则表达式应该怎么写
如;<a href="http://www.home160.net/home160sz/aspx?ID=45&Top=45" target="_blank">sss</a>
我想取出的结果为:http://www.home160.net/home160sz/aspx?ID=45&Top=45
欢迎高手指点

解决方案 »

  1.   

    http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
      

  2.   

    也可以试试
    (h|H)(r|R)(e|E)(f|F)  *=  *('|")?(\w|\\|\/|\.)+('|"|  *|>)?
      

  3.   

    可我要取出的只是一个指点的URL,而不是一个页面中所有的URL呀
      

  4.   

    using System;
    using System.Collections;
    using System.Text.RegularExpressions;public class MyClass
    {
    public static void Main()
    {
    String input = "<a href=\"http://www.home160.net/home160sz/aspx?ID=45&Top=45\" target=\"_blank\">sss</a>";
    String pattern = "<a href\\s*=\\s*[\"']{0,1}(?<URL>(http://www.home160.net[^(\"|')]*))(\"|'){0,1}[^>]*>[^<]*</a>";
    Regex r = new Regex(pattern, RegexOptions.IgnoreCase);

    String result = "";
    result = r.Replace(input, "${URL}");

    Console.WriteLine(result);
    Console.ReadLine();
    }
    }
      

  5.   

    都知道了这个URL再来获取,好像没有意义吧
      

  6.   

    (http://www\.home160\.net.*?)['"]取
    Group[1]即:
    Regex r = new Regex(rule,RegexOptions.Compiled);//rule 为正则表达式
    foreach(Match match in r.Matches(input))
    {
    match.Groups[1].ToString();
    }