免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1499 | 回复: 1
打印 上一主题 下一主题

greed/nogreed 不管怎样都不完美。。。 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-08-23 03:18 |只看该作者 |倒序浏览
发现不管用贪婪还是非贪婪,都不好进行多段匹配,似乎当非贪婪时,它住住结束判断过早
比如:

  1. @row = $string =~ m@id="row1".*?site="(.*?)".*?title="(.*?).*?id="row2".*?site="(.*?)".*?title="(.*?).*?id="row3".*?site="(.*?)".*?title="(.*?).*?id="row4".*?site="(.*?)".*?title="(.*?).*?id="row5".*?site="(.*?)".*?title="(.*?)"@ism;
复制代码


用这个去匹配这段代码:

  1.             
  2.                   Referring Site's Destination Share to pandabuy.com
  3.               
  4.               <img class="popup-help q99" src="http://media.compete.com/site_media/images/icons/helpicon.png" height="13" width="13" />
  5.             </span>
  6.           </th>
  7.                                 </tr>
  8.                         </thead>
  9.                         <tbody>
  10.                        
  11.                                 <tr class="white" id="row1" onmouseover="highlightRow(1);" onmouseout="unhighlightRow(1);">
  12.                                         <td style="width: 58px;" >1</td>
  13.                                         <td class="left">
  14.                         <a class="tmp sitelink" site="google.com" href="/referral/google.com" >google.com</a>
  15.                     </td>
  16.                                         <td title="38.3260903%">
  17.                         
  18.                             <div class="percent">38.33%</div>
  19.                             <div class="bargraph">
  20.                                 <div class="colorbar" style="width:38%"></div>
  21.                             </div>
  22.                         
  23.                     </td>
  24.                                         <td title="39.82">
  25.                                                 <span id="ref_growth">
  26.                             39.82
  27.                         </span>
  28.                         
  29.                             % <img src="http://media.compete.com/site_media/images/arrow_up.gif" />
  30.                         
  31.                     </td>
  32.                                         <td title="0.0000298%">
  33.                         
  34.                                                 <div class="percent">
  35.                                 <a href="/destination/google.com">< 0.01%</a>
  36.                             </div>
  37.                             <div class="bargraph">
  38.                                 <div class="colorbar" style="width:0%"></div>
  39.                             </div>
  40.                         
  41.                                         </td>
  42.                                 </tr>
  43.                        
  44.                                 <tr class="grey" id="row2" onmouseover="highlightRow(2);" onmouseout="unhighlightRow(2);">
  45.                                         <td style="width: 58px;" >2</td>
  46.                                         <td class="left">
  47.                         <a class="tmp sitelink" site="univision.com" href="/referral/univision.com" >univision.com</a>
  48.                     </td>
  49.                                         <td title="6.7036345%">
  50.                         
  51.                             <div class="percent">6.7%</div>
  52.                             <div class="bargraph">
  53.                                 <div class="colorbar" style="width:7%"></div>
  54.                             </div>
  55.                         
  56.                     </td>
  57.                                         <td title="First month of referral data for Referring Site">
  58.                                                 <span id="ref_growth">
  59.                             New
  60.                         </span>
  61.                         
  62.                     </td>
  63.                                         <td title="0.0050100%">
  64.                         
  65.                                                 <div class="percent">
  66.                                 <a href="/destination/univision.com">0.01%</a>
  67.                             </div>
  68.                             <div class="bargraph">
  69.                                 <div class="colorbar" style="width:0%"></div>
  70.                             </div>
  71.                         
  72.                                         </td>
  73.                                 </tr>
  74.                        
  75.                                 <tr class="white" id="row3" onmouseover="highlightRow(3);" onmouseout="unhighlightRow(3);">
  76.                                         <td style="width: 58px;" >3</td>
  77.                                         <td class="left">
  78.                         <a class="tmp sitelink" site="amazon.com" href="/referral/amazon.com" >amazon.com</a>
  79.                     </td>
  80.                                         <td title="4.6109130%">
  81.                         
  82.                             <div class="percent">4.61%</div>
  83.                             <div class="bargraph">
  84.                                 <div class="colorbar" style="width:5%"></div>
  85.                             </div>
  86.                         
  87.                     </td>
  88.                                         <td title="First month of referral data for Referring Site">
  89.                                                 <span id="ref_growth">
  90.                             New
  91.                         </span>
  92.                         
  93.                     </td>
  94.                                         <td title="0.0000901%">
  95.                         
  96.                                                 <div class="percent">
  97.                                 <a href="/destination/amazon.com">< 0.01%</a>
  98.                             </div>
  99.                             <div class="bargraph">
  100.                                 <div class="colorbar" style="width:0%"></div>
  101.                             </div>
  102.                         
  103.                                         </td>
  104.                                 </tr>
  105.                        
  106.                                 <tr class="grey" id="row4" onmouseover="highlightRow(4);" onmouseout="unhighlightRow(4);">
  107.                                         <td style="width: 58px;" >4</td>
  108.                                         <td class="left">
  109.                         <a class="tmp sitelink" site="163.com" href="/referral/163.com" >163.com</a>
  110.                     </td>
  111.                                         <td title="Sample size too small to show values">
  112.                         
  113.                             Low Sample
  114.                         
  115.                     </td>
  116.                                         <td title="Sample size too small to show a change in share value">
  117.                                                 <span id="ref_growth">
  118.                             -
  119.                         </span>
  120.                         
  121.                     </td>
  122.                                         <td title="Sample size too small to show values">
  123.                         
  124.                                                 <a href="/destination/163.com">
  125.                                 Low Sample
  126.                             </a>
  127.                         
  128.                                         </td>
  129.                                 </tr>
  130.                        
  131.                                 <tr class="white" id="row5" onmouseover="highlightRow(5);" onmouseout="unhighlightRow(5);">
  132.                                         <td style="width: 58px;" >5</td>
  133.                                         <td class="left">
  134.                         <a class="tmp sitelink" site="amazon.co.jp" href="/referral/amazon.co.jp" >amazon.co.jp</a>
  135.                     </td>
  136.                                         <td title="Sample size too small to show values">
  137.                         
  138.                             Low Sample
  139.                         
  140.                     </td>
  141.                                         <td title="Sample size too small to show a change in share value">
  142.                                                 <span id="ref_growth">
  143.                             -
  144.                         </span>
  145.                         
  146.                     </td>
  147.                                         <td title="Sample size too small to show values">
  148.                         
  149.                                                 <a href="/destination/amazon.co.jp">
  150.                                 Low Sample
  151.                             </a>
  152.                         
  153.                                         </td>
  154.                                 </tr>
  155.                        
  156.                         </tbody>
复制代码


就会漏取掉其中的东西。。。

论坛徽章:
5
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:50:282015年亚洲杯之朝鲜
日期:2015-03-13 22:47:33IT运维版块每日发帖之星
日期:2016-01-09 06:20:00IT运维版块每周发帖之星
日期:2016-03-07 16:27:44
2 [报告]
发表于 2009-08-23 11:30 |只看该作者

回复 #1 pooronce 的帖子

世上本无完美。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP