<a href="sohu.com">sohu</a>
<a href=sohu.com>sohu</a>
<a href=sohu.com style="" target="">sohu</a>
可能还有其它的一些未知类型,要求得出
sohu.com及sohu
C#.net,非常谢谢

解决方案 »

  1.   

    string s = @"<a href=""sohu1.com"">sohu1</a>
    <a href='sohu2.com'>sohu2</a>
    <a href=sohu3.com>sohu3</a>
    <a href=sohu4.com style="" target="">sohu4</a>
    "; Regex re = new Regex(@"<a[^>]*href=(""(?<link>[^""]+)""|'(?<link>[^']+)'|(?<link>[^\s>]+))[^>]*>(?<text>.*?)</a>", RegexOptions.IgnoreCase|RegexOptions.Singleline);
    foreach(Match m in re.Matches(s))
    Console.WriteLine("{0}==>{1}", m.Groups["link"].Value, m.Groups["text"].Value);or go to http://regexlib.com/search for "anchor"