小弟不会正则表达式,但现在需用到
特向各位大哥求一好的获取链接地址的正则表达式,如……<a href="http://community.csdn.net/">,要得到http://community.csdn.net/
感激不尽!!

解决方案 »

  1.   

    如果是取一个,这样stirng yourStr = ..............;
    string resultStr = "";
    Match m = Regex.Match(yourStr, @"<a\s[^>]*href=(['""]?)(?<url>[^'""\s]*)\1?[^>]*>", RegexOptions.IgnoreCase);
    if (m.Success)
    {
        resultStr = m.Groups["url"].Value;
    }
      

  2.   

    string url = "……<a href="http://community.csdn.net/">";
    url = Regex.Replace(url, @".*<a\s+href=\"(?<url>http://[^\"]*)\">.*", "${url}", RegexOptions.IgnoreCase | RegexOptions.Compiled);
      

  3.   

    如果同时取多个,这样string yourStr = ...............;
    MatchCollection mc = Regex.Matches(yourStr, @"<a\s[^>]*href=(['""]?)(?<url>[^'""\s]*)\1?[^>]*>", RegexOptions.IgnoreCase);
    foreach (Match m in mc)
    {
        richTextBox2.Text += m.Groups["url"].Value + "\n";
    }
      

  4.   

    <a.*?href=['""]*(?<url>[^'"" >]*?)['"" >]我用的这个.
    -----------------------
          CSDN 论坛助手 
      http://china-csdn.cn
      

  5.   

    <a\s[^>]*href\s*=\s*(['"]?)(?<url>[^'"\s>]*)[^>]*>
    补充一下
      

  6.   

    <a\s[^>]*href=(['""]?)(?<url>[^'""\s]*)\1?[^>]*>
      

  7.   

    public string SniffwebCode(string code, string wordsBegin, string wordsEnd)
            { 
                string NewsTitle="";
                Regex regex1 = new Regex("" + wordsBegin + @"(?<title>[\s\S]+?)" + wordsEnd + "", RegexOptions.Compiled | RegexOptions.IgnoreCase);
                for (Match match1 = regex1.Match(code); match1.Success; match1 = match1.NextMatch())
                {
                    NewsTitle = match1.Groups["title"].ToString();
                }
                    return NewsTitle;
            }在本题中 wordsBegin 为: <a href="    wordsEnd 为: ">
      

  8.   

    此正则表达式可以匹配任何 在wordbegin和wordend中的内容