首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

求匹配这种表格TR td的正则表达式,该如何解决

2012-06-14 
求匹配这种表格TR td的正则表达式取出td中数据TR aligncenter bgcolor#ffffffTD height24110

求匹配这种表格TR td的正则表达式
取出td中数据

 <TR align="center" bgcolor="#ffffff">
  <TD height="24">
  11036
  </TD>
  <TD>
  <B>
  <FONT color='#cb0100'>1&nbsp;&nbsp;6&nbsp;&nbsp;3</FONT></B>
  </TD>
  <TD>
  <A href='/result/10000975.shtml' target='_blank'><IMG src='/images/00005.gif' border='0' /></A>
  </TD>
  <TD>
  6754
  </TD>
  <TD bgcolor="#fff3db">
  1000
  </TD>
  <TD>
  --
  </TD>
  <TD bgcolor="#eeffee">
  320
  </TD>
  <TD>
  17783
  </TD>
  <TD bgcolor="#ecf5fc">
  160
  </TD>
  <TD>
  2011-02-12
  </TD>
  </TR>
   
  <TR align="center" bgcolor="#f4f4f4">
  <TD height="24">
  11035
  </TD>
  <TD>
  <B>
  <FONT color='#cb0100'>7&nbsp;&nbsp;4&nbsp;&nbsp;4</FONT></B>
  </TD>
  <TD>
  <A href='/result/10000962.shtml' target='_blank'><IMG src='/images/00005.gif' border='0' /></A>
  </TD>
  <TD>
  11958
  </TD>
  <TD bgcolor="#fff3db">
  1000
  </TD>
  <TD>
  15999
  </TD>
  <TD bgcolor="#eeffee">
  320
  </TD>
  <TD>
  --
  </TD>
  <TD bgcolor="#ecf5fc">
  160
  </TD>
  <TD>
  2011-02-11
  </TD>
  </TR>
   
  <TR align="center" bgcolor="#ffffff">


  <TD height="24">
  11034
  </TD>
  <TD>
  <B>
  <FONT color='#cb0100'>4&nbsp;&nbsp;8&nbsp;&nbsp;9</FONT></B>
  </TD>
  <TD>
  <A href='/result/10000926.shtml' target='_blank'><IMG src='/images/00005.gif' border='0' /></A>
  </TD>
  <TD>
  5505
  </TD>
  <TD bgcolor="#fff3db">
  1000
  </TD>
  <TD>
  --
  </TD>
  <TD bgcolor="#eeffee">
  320
  </TD>
  <TD>
  12954
  </TD>
  <TD bgcolor="#ecf5fc">
  160
  </TD>
  <TD>
  2011-02-10
  </TD>
  </TR>
   
  <TR align="center" bgcolor="#f4f4f4">
  <TD height="24">
  11033
  </TD>
  <TD>
  <B>
  <FONT color='#cb0100'>0&nbsp;&nbsp;6&nbsp;&nbsp;2</FONT></B>
  </TD>
  <TD>
  <A href='/result/10000919.shtml' target='_blank'><IMG src='/images/00005.gif' border='0' /></A>
  </TD>
  <TD>
  2443
  </TD>
  <TD bgcolor="#fff3db">
  1000
  </TD>
  <TD>
  --
  </TD>
  <TD bgcolor="#eeffee">
  320
  </TD>
  <TD>
  7209
  </TD>
  <TD bgcolor="#ecf5fc">
  160
  </TD>
  <TD>
  2011-02-09
  </TD>
  </TR>
   


[解决办法]

PHP code
$s = <<<eof<TR align="center" bgcolor="#ffffff">  <TD height="24">  11036  </TD>  <TD>  <B>  <FONT color='#cb0100'>1&nbsp;&nbsp;6&nbsp;&nbsp;3</FONT></B>  </TD>  <TD>  <A href='/result/10000975.shtml' target='_blank'><IMG src='/images/00005.gif' border='0' /></A>  </TD>  <TD>  6754  </TD>  <TD bgcolor="#fff3db">  1000  </TD>  <TD>  --  </TD>  <TD bgcolor="#eeffee">  320  </TD>  <TD>  17783  </TD>  <TD bgcolor="#ecf5fc">  160  </TD>  <TD>  2011-02-12  </TD>  </TR>     <TR align="center" bgcolor="#f4f4f4">  <TD height="24">  11035  </TD>  <TD>  <B>  <FONT color='#cb0100'>7&nbsp;&nbsp;4&nbsp;&nbsp;4</FONT></B>  </TD>  <TD>  <A href='/result/10000962.shtml' target='_blank'><IMG src='/images/00005.gif' border='0' /></A>  </TD>  <TD>  11958  </TD>  <TD bgcolor="#fff3db">  1000  </TD>  <TD>  15999  </TD>  <TD bgcolor="#eeffee">  320  </TD>  <TD>  --  </TD>  <TD bgcolor="#ecf5fc">  160  </TD>  <TD>  2011-02-11  </TD>  </TR>     <TR align="center" bgcolor="#ffffff">  <TD height="24">  11034  </TD>  <TD>  <B>  <FONT color='#cb0100'>4&nbsp;&nbsp;8&nbsp;&nbsp;9</FONT></B>  </TD>  <TD>  <A href='/result/10000926.shtml' target='_blank'><IMG src='/images/00005.gif' border='0' /></A>  </TD>  <TD>  5505  </TD>  <TD bgcolor="#fff3db">  1000  </TD>  <TD>  --  </TD>  <TD bgcolor="#eeffee">  320  </TD>  <TD>  12954  </TD>  <TD bgcolor="#ecf5fc">  160  </TD>  <TD>  2011-02-10  </TD>  </TR>     <TR align="center" bgcolor="#f4f4f4">  <TD height="24">  11033  </TD>  <TD>  <B>  <FONT color='#cb0100'>0&nbsp;&nbsp;6&nbsp;&nbsp;2</FONT></B>  </TD>  <TD>  <A href='/result/10000919.shtml' target='_blank'><IMG src='/images/00005.gif' border='0' /></A>  </TD>  <TD>  2443  </TD>  <TD bgcolor="#fff3db">  1000  </TD>  <TD>  --  </TD>  <TD bgcolor="#eeffee">  320  </TD>  <TD>  7209  </TD>  <TD bgcolor="#ecf5fc">  160  </TD>  <TD>  2011-02-09  </TD>  </TR>eof;if(preg_match_all('/<TR\s+align="center"\s+bgcolor="#ffffff">(.*?)<\/TR>/is',$s,$arr)){  echo '<pre />';  foreach($arr[1] as $v){    if(preg_match_all('/<td[^>]*>(.*?)<\/td>/is',$v,$brr)){      print_r($brr);    }    }} 

热点排行