<?php
$contents = '<tr class="">
<td>508982</td>
<td>08,07,01,03,04,09,05,10,06,02</td>
<td>2015-08-31 17:17</td>
</tr>
<tr class="odd">
<td>508981</td>
<td>02,03,06,04,10,05,09,01,08,07</td>
<td>2015-08-31 17:12</td>
</tr>';
preg_match_all('/<tr([\s\S]*?)>([\s\S]*?)<\/tr>/',$contents,$matched); foreach($matched[2] as $k=>$v){
preg_match_all('/<td>([\s\S]*?)<\/td>/',$v,$matched_v);
print_r($matched_v);
}

  

结果

Array
(
[0] => Array
(
[0] => <td>508982</td>
[1] => <td>08,07,01,03,04,09,05,10,06,02</td>
[2] => <td>2015-08-31 17:17</td>
) [1] => Array
(
[0] => 508982
[1] => 08,07,01,03,04,09,05,10,06,02
[2] => 2015-08-31 17:17
) )
Array
(
[0] => Array
(
[0] => <td>508981</td>
[1] => <td>02,03,06,04,10,05,09,01,08,07</td>
[2] => <td>2015-08-31 17:12</td>
) [1] => Array
(
[0] => 508981
[1] => 02,03,06,04,10,05,09,01,08,07
[2] => 2015-08-31 17:12
) )

  

参考:

http://www.5idev.com/p-php_preg_match.shtml

http://www.5idev.com/p-php_regular_syntax_1.shtml

http://www.5idev.com/p-php_regular_syntax_2.shtml

php正则表达式获取表格内容的更多相关文章

  1. JS正则表达式获取分组内容实例

    JS正则表达式获取分组内容. 支持多次匹配的方式: var testStr = "now test001 test002"; var re = /test(\d+)/ig; var ...

  2. 正则表达式获取body内容

    最近项目需要,要弄个正则表达式获取body的内容. 用过angularjs就知道,很多时候要写指令时引用templateUrl的时候.template的内容root是不能包含多个节点的,否则就报错. ...

  3. js遍历获取表格内数据方法

    1.一般的表格结构如下 <table> <tr> <td>id</td> <td>name</td> </tr> & ...

  4. PHP用正则批量替换Img中src内容,用正则表达式获取图片路径实现缩略图功能

    PHP用正则批量替换Img中src内容,用正则表达式获取图片路径实现缩略图功能 网上很多正则表达式只能获取或者替换一个img的src内容,或者只能替换固定的字符串,要动态替换多个图片内容的试了几个小时 ...

  5. php用正则表达式获取网站的标题内容

    已知网站的网址,用php获取网站的内容. 编写正则表达式. 用preg_match_all函数获取标题内容. $url='http://www.m-ivi.com'; $content=file_ge ...

  6. Java 正则表达式获取两个字符中间的内容

    利用 正则表达式 获取两个字符串中间的值 直接上代码吧,不是很难. public static void main(String[] args) { // 内容 String value = &quo ...

  7. 跨平台信息获取小工具第三版本(增加了继承、多线程、异常处理模块、excel表格内容剔除空格)

    # coding=utf-8 import threadingimport paramikoimport osimport timeimport xlrdimport xlwtimport openp ...

  8. PHP用正则批量替换Img中src内容,用正则表达式获取图片路径实现缩略图功能

    PHP用正则批量替换Img中src内容,用正则表达式获取图片路径实现缩略图功能 网上很多正则表达式只能获取或者替换一个img的src内容,或者只能替换固定的字符串,要动态替换多个图片内容的试了几个小时 ...

  9. JS使用正则表达式获取小括号、中括号及花括号内容的方法示例

    本文实例讲述了JS使用正则表达式获取小括号.中括号及花括号内容的方法.分享给大家供大家参考,具体如下: JS 正则表达式 获取小括号 中括号 花括号内的内容 <!DOCTYPE html> ...

随机推荐

  1. hadoop2.5.1搭建(一)

    1.1配置 1.1.1修改hosts vi /etc/hosts 192.168.220.64 cluster4 192.168.220.63 cluster3 1.2安装jdk rpm安装 rpm ...

  2. hql语句关联查询(select new )

    在  new bean()中,对象里要有其构造方法,查询参数必须是构造方法中的参数,get set也要同步 类似于 String hql= "select  new A(a.id, a.na ...

  3. iptable软路由

    http://xstarcd.github.io/wiki/Linux/iptables_forward_internetshare.html # 默认丢弃转发,所有内网流量不能访问外网卡 iptab ...

  4. python 多行匹配

    content = ''' abcdefg hijklmn opq rst uvw xyz ''' r = re.compile('\S+cde\S+|\S+klm\S+|^xyz$', re.MUL ...

  5. 复杂的sql 一对多查询

    SELECT distinct       u.Name as UserName,       a.OrderId,       (       select  d.SignCity from T_O ...

  6. 在PHP应用中简化OAuth2.0身份验证集成:OAuth 2.0 Client

    在PHP应用中简化OAuth2.0身份验证集成:OAuth 2.0 Client   阅读目录 验证代码流程 Refreshing a Token Built-In Providers 这个包能够让你 ...

  7. 设计模式-代理模式(Proxy)

    应用场景: 领导都有秘书,一般会代理领导的部分职能角色,处理签字.报销.开会等任务.很多新人可能都只知道秘书的存在,毕竟每天与其打交道,不知道领导的存在.但是领导的的确确是真实存在的. 场景说明: 代 ...

  8. Rich控件一

    Calendar控件 Calendar控件用来在Web页面中显示日历中的可选日期,并显示与特定日期关联的数据. 控件声明代码如下: <asp: Calendar id=" Calend ...

  9. DataGridView取消默认选中行

    DataGridView在添加数据后会默认选中第 一个单元格或者第一行,我就想取消它的默认选中行.在DataGridView绑定数据之后加上了ClearSelection().这样一来,不论是启动窗体 ...

  10. jquery导航二级栏目下拉

    <div class="Nav_L L"> <ul> <li><a href="" title="" ...