<a href="http://www.pc-boy.com" class="a1">阿呆在线</a>
在C#中 我要取这串字符中的"http://www.pc-boy.com" 和阿呆在线 保存到数组中
另外要是有一个特证就是<a></a>中要有class="a1" 才取<a(.+?)href=[\"\']?(.+?)[\"\'\s>]+(.+?)[>](.+?)<\/a>
这个只能取所有的:<A></A>

解决方案 »

  1.   

    using System;
    using System.Collections;
    using System.Text.RegularExpressions;public class MyClass
    {
    public static void Main()
    {
    String input = "<a href=\"http://www.pc-boy.com\" class=\"a1\">阿呆在线</a>";
    String pattern = "<a\\s+href\\s*=\\s*[\"']{0,1}(?<1>[^\"']*)[\"']{0,1}\\s+class\\s*=\\s*[\"']{0,1}a1[\"']{0,1}[^>]*>(?<2>[^</]*)</a>";
    Regex r = new Regex(pattern, RegexOptions.IgnoreCase);

    Console.WriteLine("Result : \n{0}", r.Replace(input, "${1}\n${2}"));
    Console.ReadLine();
    }

    }
      

  2.   

    <a href="http://www.pc-boy.com" class="a1">阿呆在线</a>(3652)  这种在网页上显示为:阿呆在线(152) 这个链接后的数字为点击数;如果要取阿呆在线和阿呆在线的网址 这个正则表达式要怎么改一下呀就是加了两个括号及里面为任意的0-9之间的数