Beispiel #1
0
assert($s->matchPos() === 1);
assert($s->pos() === 1);
// but check pos hasn't moved.
$s->check('/\\d+/');
assert($s->match() === '123456789');
$s->unscan();
//repeat
assert($s->pos() === 1);
assert($s->matchGroup(0) === '123456');
assert($s->matchGroup('one') === '1');
assert($s->matchGroup(2) === '56');
assert($s->matchGroup(3) === '6');
assert($s->matchPos() === 1);
$s->reset();
// now check scan_until
assert($s->scanUntil('/5/') === '01234');
assert($s->match() === '01234');
assert($s->matchGroup(0) === '01234');
assert($s->matchGroups() === array(0 => '01234'));
assert($s->pos() === 5);
// now check index
$s->reset();
assert($s->index('/0/') === 0);
assert($s->index('/2/') === 2);
assert($s->index('/21/') === -1);
$s->pos(5);
assert($s->index('/0/') === -1);
assert($s->index('/6/') === 6);
// Now the automation functions
$s->string('012 45 ');
$s->addPattern('zero', '/0/');