如何同时匹配<a....>....>和<a.....>这两种情况?
<a href="http://ngoto.sohu.com/D=SOHU/A=a7d32df87bb9d10d785c2a54aeb9c71d/T=K1/>http://www.shgao.com" target=_blank class=blue1>
<a class=blue3 href="http://women.sohu.com/s2006/shanliangzhilv/"
target=_blank>

解决方案 »

  1.   

    是这样?
    string t1 = "asd<a href=\"about:blank\">asssss>213";
    string t2 = "wqe<a href=\"about:blank\">asssss</a>da";
    string t3 = "2314<a href=\"about:blank\">asssssweq32";
    string pattern = @"\<a .*?>.*?(>|</a>)";
    Console.WriteLine(Regex.IsMatch(t1, pattern));
    Console.WriteLine(Regex.IsMatch(t2, pattern));
    Console.WriteLine(Regex.IsMatch(t3, pattern));
      

  2.   

    把这段代码中<a>标志及其中内容去掉即可
    <A class=blue3 href="http://women.sohu.com/s2006/shanliangzhilv/"
    target=_blank>“闪亮计划”选手奇招争霸十强</a>
    <A class=blue3 href="http://gd.sohu.com/s2006/2006gzjlp/"
    target=_blank>2006中国(广州)国际纪录片大会</a>
    <A class=blue3 href="http://yule.sohu.com/s2006/chongqingweishishendiao/"
    target=_blank>重庆卫视:评神雕侠侣赢金庸全集</a><br>
    <A class=blue3 href="http://finance.cctv.com/special/C16860/20061204/104065.shtml"
    target=_blank>别误读《大国崛起》:总编导访谈</a>
    ·<a href="http://ngoto.sohu.com/D=SOHU/A=a7d32df87bb9d10d785c2a54aeb9c71d/T=K1/>http://www.shgao.com" target=_blank class=blue1>商告</a>|<a href="http://61.135.132.134/goto.php?aid=77&pid=708"  target=_blank class=blue1>搞怪彩铃最酷音乐</a> <a href="http://pic.sogou.com/pics?query=%D3%D5%BB%F3%C5%AE%C0%C9&mode=1&sid=&pid=&duppid=&pid=32008101" target=_blank class=blue1>全球十大诱惑女郎</a><br>
    ·<a href="http://ngoto.sohu.com/D=SOHU/A=bd319e06b2b14fd478965429b8da221a/T=K1/>http://www.010eye.com/ggao/index.htm" target=_blank class=blue1>近视手术的十大问题</a><a href="http://ngoto.sohu.com/D=SOHU/A=a13f314a294369dcb2aef3fd52b01e19/T=K1/>http://ad.cn.doubleclick.net/clk;55426932;14671498;t?http://www-900.ibm.com/cn/services/innovation/cio/"  target=_blank class=blue1>IBM《CIO创新启示》</a><br>
    ·<a href="http://adc.go.sohu.com/200612/189eacdae6e7d9b1509c446c72cb26d4.php" class=blue1 target=_blank>海尔自由播高清流媒体电视与我的生活!</a><br>
    ·<a href="http://adc.go.sohu.com/200611/7991d59d9b59c3afafd2b4ed7dd615dc.php" target=_blank class=blue1>热烈祝贺F8荣获北京车展中国首发新车大奖</a><br> </td></tr>
      

  3.   

    Regex.Replace(t3, pattern, "");
      

  4.   

    string s = "...............";
    Regex.Replace(s, @"\<a .*?>.*?(>|</a>)", "");
      

  5.   

    string s = "...............";
    Regex.Replace(s, @"\<a .*?\>.*?\</a\>", "");
      

  6.   

    to 0009(佛裂):I cann't get the correct result.
      

  7.   

    string s = "你要处理的字符串";
    Regex.Replace(s, @"\<a .*?\>.*?\</a\>", "");-_-*不好意思前面发了好多错误的
      

  8.   

    Regex.Replace(s, @"<a(?!</a>).*",string.Empty,RegexOptions.IgnoreCase);