<div class="lf"><cite><a href="http://t.sina.com.cn/1685890464/wr0lzjtGKn"><strong date="2010-08-29 11:10:43">今天 11:10</strong></a></cite>
<strong lang="CL1006">来自</strong><cite><a href="http://wap.uc.cn/ucpack/dlmobile/control/index.php?oper=ptrn_sina_sns&page=web" target="_blank">UC浏览器</a></cite></div>
      <div class="lf"><cite><a href="http://t.sina.com.cn/1652867473/wr0lzjscPB"><strong date="2010-08-29 10:41:08">今天 10:41</strong></a></cite>
<strong lang="CL1006">来自</strong>新浪微博</div>
写一个正则表达式,可以同时匹配到“UC浏览器”和“新浪微博”? (target=\x22_blank\x22>(?<source>.*?)</a></cite></div>)|(来自</strong>(?<source>.*?)</div>)
为什么不行呢?

解决方案 »

  1.   

    在楼主正则基础上做的修改target=\x22_blank\x22>(?<source>[^<>]*)</a></cite></div>|来自</strong>(?<source>[^<>]*)</div>
      

  2.   

    这个能得到得到“UC浏览器”和“新浪微博”
                string str = @"<div class=""lf""><cite><a href=""http://t.sina.com.cn/1685890464/wr0lzjtGKn""><strong date=""2010-08-29 11:10:43"">今天 11:10</strong></a></cite>
    <strong lang=""CL1006"">来自</strong><cite><a href=""http://wap.uc.cn/ucpack/dlmobile/control/index.php?oper=ptrn_sina_sns&page=web"" target=""_blank"">UC浏览器</a></cite></div>
          <div class=""lf""><cite><a href=""http://t.sina.com.cn/1652867473/wr0lzjscPB""><strong date=""2010-08-29 10:41:08"">今天 10:41</strong></a></cite>
    <strong lang=""CL1006"">来自</strong>新浪微博</div>";            Regex reg = new Regex(@"((?<=target=[^<>]*?>).*?(?=</a></cite></div>))|((?<=来自</strong>)[^<>]*?(?=</div>))");            foreach (Match m in reg.Matches(str))
                    Console.WriteLine(m.Value);