ddliu/requery

使用正则表达式查询文本数据。

v0.1.1 2014-12-17 11:10 UTC

This package is auto-updated.

Last update: 2024-09-13 22:25:36 UTC


README

使用正则表达式查询文本数据。

用法

use ddliu\requer\Context;

$q = new Context($content);
$q->find('#<table>.*</table>#Uis')
    ->then(function($table) {
        $table->findAll('#<th>(.*)</th>#Uis')
            ->each(function($th) {
                echo 'th: '.$th[1]."\n";
            });
    })
    ->then(function($table) {
        $table->find('#<tbody>.*</tbody>#Uis')->findAll('#<tr>.*</tr>#Uis')
            ->each(function($tr) {
                $tr->findAll('#<td>(.*)</td>#Uis')
                    ->each(function($td) {
                        echo 'td: '.$td[1]."\n";
                    });
            });
    });